This is an amusing bug that's taken me a while to track down. I'm working on a visual effect that uses two scripts placed in a single MagicEffect. Each script does different things at different intervals, and this was handled by RegisterForSingleUpdate/OnUpdate sequences. I found, though, that all the events in all scripts were firing at the same time.
After barking up several wrong trees to try and figure out just WTF what going wrong, I discovered the following:
RegisterForSingleUpdate fires the OnUpdate event in all scripts attached to the current MagicEffect.
To test this, I added the following script to my magiceffect:
Scriptname MagicEffectBugTest extends activemagiceffect{This should never do anything.}Event OnUpdate() Debug.Trace(Self + ": This event should never, ever be fired!")EndEvent
As you can see, the text in the OnUpdate event should never show up in the log because the script never registers for an update. However, as soon as one of the other scripts attached to the MagicEffect uses RegisterForSingleUpdate, the above script makes the debug entry in the log file.
Now that I understand what's happening, it makes sense; after all, it is the ActiveMagicEffect that's being registered for an update, not the script attached to it. But I found it counter-intuitive enough for it to trip me up for longer than I'd like to admit, so I thought I'd share this little tidbit in the hopes that it doesn't bite anyone else.