Variables#
Variables for all sprites#
To declare a variable for all sprites, assign to it in stage.gs
.
Variables for this sprite only#
To declare a variable for this sprite only, assign to it in the sprite's .gs
file.
Local variables (for a procedure only)#
Local variables is a feature of goboscript, which lets you define a variable which can only be used inside a procedure and is not accessible outside of it.
In the compiled Scratch project, the variable x
will be named as my_procedure.x
.
Note
Local variables will have unexpected behavior if the procedure is recursive.
Set variable#
Change variable#
Change variables using a operator#
x += 1;
x -= 1;
x *= 2;
x /= 2;
x //= 2; # Floor Division
x %= 2;
x &= "str";
x++; # Increment by 1
x--; # Decrement by 1
The -=
statement is implemented using the change variable block.