Script-based switches
Script-Based Switches (Written by Peter O.)
This script section is designed to enable advanced control over event handling by assigning certain switches to an arbitrary script. This script also contains support for temporary self-switches and event-specific variables.
For script-based switches, the switch is true as long as the condition on the switch's name remains true. Script-based switches are distinguished from regular switches using the prefix "s:". Be aware that due to the size limit on a switch's name, it may be necessary to use this kind of switch to call other methods that return a true or false value. Methods on script-based switches are called within the context of the Game_Event class.
Only switches on map events are supported, not those on common events, and only within the "Conditions" section of an event page.
Temporary Self Switches
Each event in the game comes with a set of temporary self switches. This set is cleared whenever a map is entered. To check whether a temporary self switch is on, use a switch named "s:tsOn?(X)" where X is one of "A", "B", "C", or "D". To check whether it's off, use a switch named "s:tsOff?(X)". To turn a temporary self switch on or off, use a script like:
setTempSwitchOn("A")
or:
setTempSwitchOff("A")
Event-Specific Variables
Each event in the game comes with its own variable, which can be used for any purpose. To retrieve a variable, call the script function "getVariable", and to set the value of the current event's variable, call the script function "setVariable(X)", where X is the value to set to the variable. To check the variable's value in an event page's condition, use the event function "variable" (or "varAsInt", meaning "variable as integer") to help you. For example, to check whether the event's variable is equal to 1, you would use a switch named: "s:varAsInt==1".
Checking Self Switches
A script-based switch may be useful, among other things, for checking whether a self-switch is off as one of an event page's conditions. This is possible by using a switch whose name is: s:isOff?("A") etc.