Difference between revisions of "Category:Troubleshooting"
→Gamemode Scripts: Flag variable and 'if' test
imported>Haama (→CPU-Hungry Script Functions: Only a problem if run every frame) |
imported>Haama (→Gamemode Scripts: Flag variable and 'if' test) |
||
Line 366: | Line 366: | ||
== Gamemode Scripts == | == Gamemode Scripts == | ||
Avoid using gamemode scripts wherever possible. Use quest scripts if you can, or try to find ways to put as much of the script work into OnLoad, OnEquip, and ScriptEffectStart blocks as possible. | Avoid using gamemode scripts wherever possible. Use quest scripts if you can, or try to find ways to put as much of the script work into OnLoad, OnEquip, and ScriptEffectStart blocks as possible. | ||
If you need to use a GameMode block, use an 'if' test or a flag so the code will only run when necessary. For instance, if you need to run an item script whenever the player hits a switch, place this on the switch: | |||
<pre>scn YourSwitchScript | |||
short Working | |||
begin onActivate | |||
set Working to 1 | |||
end</pre> | |||
and this on the item: | |||
<pre>scn YourItemScript | |||
begin GameMode | |||
if YourScript.Working | |||
... | |||
endif | |||
end</pre> | |||
== CPU-Hungry Script Functions == | == CPU-Hungry Script Functions == |