Difference between revisions of "Crashes"
→Activate Self: Added explanation of a related infinite recursion situation.
imported>Syscrusher m (→Activate Self: Typo correction) |
imported>Syscrusher (→Activate Self: Added explanation of a related infinite recursion situation.) |
||
Line 83: | Line 83: | ||
Activate player, 1 | Activate player, 1 | ||
end</pre> | end</pre> | ||
It is also usually unwise to self-activate an object from within its [[OnActivate]] block with the [[OnActivate]] bit true, as this almost always leads to infinite recursion and a crash. | |||
'''Wrong:''' | |||
<pre>begin OnActivate | |||
... | |||
Activate player, 1 | |||
end</pre> | |||
'''Right:''' | |||
<pre>begin OnActivate | |||
... | |||
Activate player, 0 | |||
end</pre> | |||
The default on that bit is zero, but it is a good practice to explicitly specify it as a reminder to yourself. | |||
This situation arises (for example) if you have a container with a script that does something when activated but then lets the player or NPC go ahead and open the container in the usual way. The [[Activate]] call to actually open the container does not need to recurse into your OnActivate script. | |||
== Activating a Container (including NPC) == | == Activating a Container (including NPC) == |