Mathematical and arithmetic expressions can be written without using the opcode. This is much easier and faster.
INC, This command is an alternative to the usual addition. It increases the value of the first parameter to the number transmitted by the
second parameter.
Same as:
By the variable $Var in both versions will be an 10.
Let me remind you that if the second number integer, is a Float type variable, then the compiler automatically converts the number of fractional.
This command is useful if you only need to add one to the variable, as the second parameter by default is 1.
Same as:
DEC, This command is an alternative to the usual addition. It decreases the value of the first parameter to the number transmitted by the
second parameter.
Same as:
MUL, This command is an alternative to the usual addition. It multiplies the value of the first parameter to the number transmitted by the
second parameter.
Same as:
DIV, This command is an alternative to the usual addition. It divides the value of the first parameter to the number transmitted by the
second parameter.
Same as:
The procedure calculates the square SQR variable. I.e. it is a replacement operation of multiplication by the variable itself:
Same as:
Random
Thus, the first is for float-point values, the second opcode is for random INT
Both can be represented as this:
As you can see, the compiler chooses the opcode, depending on what type of parameters it has,
(e.g. floating-point parameter would be something like, (0.0), where as a INT would be something like (80), for example).
That is how Sanny Builder gets the correct opcode.
If the type is unknown or is not a Integer or Float, the compiler will report an error.
Alloc
As in the present main.scm stored variables and that the DMA(Direct Memory Addresses). This is beyond the scope of this article,
although it may be later described.
So, the team Alloc. It sets the memory address for a variable with a character name:
The variable $PLAYER_CHAR will then be compiled as $12.
When using the command Alloc you can build a group of variables in a row, turning them this way in the elements array:
These variables are now an array. Look at this script code:
Missions define list, it has the numbers of missions. Any mission team started start_mission.
But you must remember these numbers are not always convenient.
Therefore, Sanny Builder was made to replace the number of mission in its name. Name - in this case, the name tags are written in the same block.
Thus, to start the 2nd mission you need to write the following:
You can access the list of names by pressing Ctrl(Strg) + Space in Sanny Builder. The cursor should be after start_mission, before the number of
that mission.
INC, This command is an alternative to the usual addition. It increases the value of the first parameter to the number transmitted by the
second parameter.
- Code:
$Var += 10
Same as:
- Code:
Inc($Var, 10)
By the variable $Var in both versions will be an 10.
Let me remind you that if the second number integer, is a Float type variable, then the compiler automatically converts the number of fractional.
This command is useful if you only need to add one to the variable, as the second parameter by default is 1.
- Code:
$Var += 1
Same as:
- Code:
Inc($Var)
DEC, This command is an alternative to the usual addition. It decreases the value of the first parameter to the number transmitted by the
second parameter.
- Code:
$Var -= 10
Same as:
- Code:
Dec($Var, 10)
MUL, This command is an alternative to the usual addition. It multiplies the value of the first parameter to the number transmitted by the
second parameter.
- Code:
$Var *= 5
Same as:
- Code:
Mul($Var, 5)
DIV, This command is an alternative to the usual addition. It divides the value of the first parameter to the number transmitted by the
second parameter.
- Code:
$Var /= 5
Same as:
- Code:
Div($Var, 5)
The procedure calculates the square SQR variable. I.e. it is a replacement operation of multiplication by the variable itself:
- Code:
$Var *= $Var
Same as:
- Code:
Sqr($Var)
Random
- Code:
0208: $Var = random_float 10.0 20.0
0209: $Var = random_int 20 100
Thus, the first is for float-point values, the second opcode is for random INT
Both can be represented as this:
- Code:
$Var = Random(20, 100)
As you can see, the compiler chooses the opcode, depending on what type of parameters it has,
(e.g. floating-point parameter would be something like, (0.0), where as a INT would be something like (80), for example).
That is how Sanny Builder gets the correct opcode.
If the type is unknown or is not a Integer or Float, the compiler will report an error.
Alloc
As in the present main.scm stored variables and that the DMA(Direct Memory Addresses). This is beyond the scope of this article,
although it may be later described.
So, the team Alloc. It sets the memory address for a variable with a character name:
- Code:
Alloc($PLAYER_CHAR, 12)
The variable $PLAYER_CHAR will then be compiled as $12.
When using the command Alloc you can build a group of variables in a row, turning them this way in the elements array:
- Code:
Alloc($Array, 30)
Alloc($Value2, 31)
Alloc($Value3, 32)
Alloc($Value4, 33)
These variables are now an array. Look at this script code:
- Code:
Alloc($Array, 30)
Alloc($Value2, 31)
Alloc($Value3, 32)
Alloc($Value4, 33)
var
$Array: array 4 of Integer
$Result: Int
end
$Value3 = 0x64
$Index = 0x2
$Result = $Array[$Index]
Player.Money($PLAYER_CHAR) += $Result // + 0x64 = 100
Missions define list, it has the numbers of missions. Any mission team started start_mission.
- Code:
DEFINE MISSION 2 AT @INTRO
But you must remember these numbers are not always convenient.
Therefore, Sanny Builder was made to replace the number of mission in its name. Name - in this case, the name tags are written in the same block.
Thus, to start the 2nd mission you need to write the following:
- Code:
start_mission intro
You can access the list of names by pressing Ctrl(Strg) + Space in Sanny Builder. The cursor should be after start_mission, before the number of
that mission.