Directives
Preprocessing directives are unique keywords that alter the compiler's behavior. They start with a dollar sign $
and enclosed within curly braces{}
.
$INCLUDE
Allows to insert the content of an external text file in the current file. If the compiler finds this directive it opens the file at the location provided as the parameter and proceeds from the code written in the included file. When it reaches the end of the included file it returns back to the previous file.
Syntax:
If the file path is relative, the compiler scans directories in the following order to find the file:
directory of the file with the directive
data
folder for the current edit modeSanny Builder root directory
the game directory
If none of these directories contains a requested file the compiler throws an exception.
You may use this directive unlimited number of times. The included files may contain this directive too.
A shorter form of this directive is $I
.
$INCLUDE_ONCE
Similar to {$INCLUDE}
, with the only difference being that if the code from a file has already been included, it will not be included again, and the directive is silently ignored.
$EXTERNAL
Makes the compiler to treat the file as an external script. Meaning, the resulting output file will be header-less and with relative label offsets, as an .scm
file from the script.img
. Using this directive requires that the file contains only one script or a single mission.
An alternative way to get such file is the debug option SKIP_SCM_HEADER
. This option could be enabled in the console or from the dropdown list on the main toolbar.
Syntax:
A shorter form of this directive is $E
.
$CLEO
An analogue of the $E
one, but the compiler automatically copies an output file to the game\CLEO
directory. The file also gets an extension provided as the directive parameter.
Syntax:
extension
is an optional parameter specifying the file extension of the output file. It starts with the period character .
. If no extension is present, the compiler uses the default value .cs
So this directive is the perfect solution to make a CLEO script.
{$CLEO}
also implies {$USE CLEO}
$NOSOURCE
Prohibits the compiler from including a source code of the script.
Without this directive when either the directive $EXTERNAL
or $CLEO
is present and the option Add extra info to SCM
is enabled, Sanny Builder adds the source code into an output file.
Syntax:
$OPCODE
Registers a custom opcode via the script.
All the opcodes definitions are contained in a special file, one for each supported game. But sometimes it's necessary to add a custom opcode to use in the current script. $OPCODE
makes it possible without touching the INI file.
Syntax:
or
or
opcode definition
- it accepts an definition in the same format as the INI file.
path\to\file
- this directive also accepts a file name as its parameter. This file must contain only opcodes definitions to be loaded. If a relative path is provided, the compiler scans directories using the same rules as for $INCLUDE.
When used without any parameter, this directive reloads the original opcodes definitions file and reverts all changes made.
A shorter form of this directive is $O
.
$USE
Allows the compiler to use a custom instruction set (an extension).
You can enable multiple extensions by separating them with commas.
$VERSION
This directive is deprecated since v3.1.0
Sets what version of opcodes to use during compilation.
Syntax:
X
- edit mode IDy
- parameters order0
- original: 0, 1, 2, etc1
- custom order, some parameters reordered
zzzz
- opcodes version
By default the compiler uses the version current_edit_mode.1.0000
.
$VERSION_RESTORE
This directive is deprecated since v3.1.0
Restores the version to the value prior to using $VERSION
.
Syntax:
Last updated