To use a global variable as a Boolean flag.
There are 100 possible global variables. They are indexed 0 to 99. You set the index by using the command globalvar=x where x is 0 to 99. Whenever you set the index then that is the global variable used for the conditions or actions needed. globalvar=x is also an action.
There are three actions that are used after the global variable is set:
1. decvar=x
2. incvar=x
3. setvar=x
You can place the following code in the script of an entity or trigger zone that is always being accessed every game loop. You can set another script, say from a character, dynamic entity, or triggers zone, by activateifused command. Use the desired activate number.
:activated=1,globalvar=1:setvar=1,activate=100,state=10
:activated=2,globalvar=2:setvar=1,activate=100,state=20
;you only want to run the activated test once so reset the activate number to a value that will not be used again until you want to use it. If you want to do more actions then set a state that corresponds to that activation.
Now you want to do some actions in accordance with the global variable that was set to 1.
You will need to use one of the conditions. There are four conditions.
1. varequal=x
2. vargreater=x
3. varless=x
4. varnotequal=x
where x is the value that is equal, greater, less, or not equal.
;For trigger zone
:state=0,plrwithinzone=1:state=1
;set the global variable index
:state=1:globalvar=1,state=2
;check to see if global variable #1 is set to 1
:state=2,varequal=1:state=10
;if not and player leaves zone then go back to state 0
:state=2,plrwithinzone=0:state=0
;start the actions you want to perform
:state=10:(actions)
There are a lot of different ways to script what you need to do. What you need to remembers is to set the global variable index. Once it is set then all other conditions and actions will refer to that global variable. Also remember that if the global variable index is set in one script and then it is set in another script before you take action on it, then the index is changed and you may not be taking action on the right script. I have done this several times since I do a lot of scripting. It is also somewhat difficult to debug.
Addendum:
Plys mod v1.09 for named variables has been implemented in v1.18. However, I'm not sure how they are used yet. It looks like that regardless of it being a named variable or an index, there are still only 100 variables.