Variable types |
Once you want to create something a little bit more complicated you will need to use variables. Next to bools, which can only be true or false you can use numbers and strings. (Strings are textlines, for the non coders)
Numbers and strings are handled within your scripts. The scriptcommands setnum and setstring will set a specified value to a variable name.
setnum
(myNumber ; 47) setstring (myText ; Spacko) |
Using variables :
These values can be used in textlines or as parameters in other scriptcommands by using square brackets
:
speech (self; I am a [myText] and my number is [mynumber].) |
This will output the values of the two variables in a speechtext of a character.
loadroom ( [myText]
) wait ( [mynumber] ) |
This ,on the other hand will load a room called Spacko and then pause the script for 47 seconds.
You can generate random number with the scriptcommand randomnum.
randomnum (number ; 10) |
This will generate a number between 1 and 10 under the name "number".
Calculations :
Numbers can be calculated with standard math operators.
setnum (calc ; [num1] + [num2] * [num3] / [num4]) |
Multiplication and division before addition and subtraction. When you output a number, it will be rounded. Internaly the number will be saved as the exact value. You can also divide to a whole number by using a " : ".
Increasing, decreasing :
Numbers can be increased and decreased by a specified value.
setnum (num1 ; +1) is the same as setnum (num1 ; [num1] + 1) |
Compare :
With if_num and if_string you can compare the values of variables with another value. When using numbers you can also use < and > to check for a range :
if_num (number ; > 30) |