Difference between revisions of "Crashes"
m
→Activating a Container (including NPC): Typo correction
imported>Arthmoor (→Deleted References: Updated for -30,000 value which does not generate CS errors.) |
imported>Syscrusher m (→Activating a Container (including NPC): Typo correction) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 76: | Line 76: | ||
</pre> | </pre> | ||
you can cause an CTD. It seems that self-activation causes the entire script to run from the top, including the [[GameMode]] block, and so will [[Activate]] itself infinitely. You can prevent this by placing the [[OnActivate]] block before the self-activation, as such: | you can cause an CTD. It seems that self-activation causes the entire script to run from the top, including the [[GameMode]] block, and so will [[Activate]] itself infinitely. You can prevent this by placing the [[OnActivate]] block before the self-activation, as such: | ||
<pre>begin | <pre>begin onActivate | ||
... | ... | ||
end | end | ||
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) == | ||
If you meet all of these conditions: | If you meet all of these conditions: | ||
#[[Activate]] a [[Container]], so that you run | #[[Activate]] a [[Container]], so that you run its [[OnActivate]] block, that is: | ||
<pre>YourContainer.Activate player, 1</pre> | <pre>YourContainer.Activate player, 1</pre> | ||
#from an [[Object scripts|Object Script]] (and maybe a [[Magic effect scripts|Magic Effect Script]], but a [[Quest scripts|Quest Script]], direct activation, or dialog script would be safe) | #from an [[Object scripts|Object Script]] (and maybe a [[Magic effect scripts|Magic Effect Script]], but a [[Quest scripts|Quest Script]], direct activation, or dialog script would be safe) |