- 190
- Posts
- 15
- Years
- Seen Apr 14, 2016
I'll explain :)
A variable is just a simple number - there are quite a few variables that have not been used in the original game and those are the ones you should use for your scripts. You should not use 4050 over and over again, but you should use different variables for each script - I recommend writing down the ones you use and just keep going forward (i.e. next variable is 4051).
All unused variables in the game are set to 0 to start with. In order to change the number a variable is set to, you use the setvar command (setvar stands for set variable).
The most important things are the Var Number and Var Value boxes in A-Map. For instance, if you put 4050 as the var Number and 0000 as the Var Value for a script, that script will only activate when stepped on if variable number 4050 is set to the value 0. Since all variables are automatically set to 0 at the start of the game, the script will activate the first time you step on it, presuming you do not change the variable before hand in any other script.
In order to prevent the script from running again, you just need to set the variable to something other than the Var Value you have given the script - the best number being the next in sequence.
So, in a script you would want to happen only the first time it is stepped on, and not again, you would write "setvar 0x4050 0x1" - this would set the value of variable 4050 to 0001. Since it is set to 0001, it will not activate the next time it is stepped on, because you have told the script in A-Map to only activate when variable 4050 is set to 0.
The reason you don't want to use 4050 or any other variable over and over again for different scripts, is because you'll likely be changing the variable's value - the only reason the scripts should share the same variable number is if they are somehow related to or dependent on each other, like if one script should only activate once another script has been completed.
I hope all that makes sense. :)
I thought the checkflag/setflag sequence did that? sorry to bother you but can u explain the difference between variables and flags?