×
Меню
Индекс

MSFD Controlling global scripts

 
These function are used to control global scripts. Global scripts have to be started with the StartScript function (either from another local or global script or from a dialogue result field) and a running script can be terminated with the StopScript function.
 
Tribunal "Start Scripts" in a plug-in start executing each time the game is loaded. If a Tribunal Start Script is terminated with a 'StopScript', it will start up again the next time the game is loaded - see the Tip and Tricks section on "Detecting when a player does a load from savegame". (Forum info / DinkumThinkum).
To my knowledge these functions do not work with local scripts attached to objects, you can however start and stop "targeted scripts" by using an object "fix": "ObjectID->StartScript" (for more info see the Tips and Tricks section on targeted scripts).
 
StartScript, "ScriptName"
This starts the specified script.
 
Warning: When you use startscript, all the scripts that have been run before you called startscript will be re-run, so scripts could be run more than once in the same frame.
 
[no fix?] ScriptRunning, "ScriptName" (returns Boolean/short)
The ScriptRunning function returns 1 if a script is running, 0 if it's not running:
 
 
if ( ScriptRunning, CharGen == 0 )
     StartScript CharGen
Endif
 
 
StopScript, "ScriptName"
Stops the specified script
 
Note: If you use 'StopScript' from inside the global script you're terminating, it doesn't actually terminate the script immediately. Instead, the script continues executing to the 'End' statement, and then terminates. So you still need to use "Return" if you don't want the rest of the script to be processed.
 
StopScript can also be used to construct do-once conditions for global scripts in a very clean way by self-terminating the script:
Begin do-once_script
 
[…]; do stuff here
 
StopScript do-once_script
End