RegisterForUpdate - Form: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
imported>Perdev
(Important warning)
imported>Perdev
mNo edit summary
Line 24: Line 24:
RegisterForUpdate(10.0)
RegisterForUpdate(10.0)
</source>
</source>
== Notes ==
*Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
*Subsequent calls to RegisterForUpdate will override previous ones - i.e. calling it back to back will result in updates at the second call's interval, but not the first. It does not interfere with updates registered via RegisterForSingleUpdate.


==Important Warning==
==Important Warning==
Line 36: Line 40:
Anyway, all of those problems are avoided by using [[RegisterForSingleUpdate - Form|RegisterForSingleUpdate]] instead:
Anyway, all of those problems are avoided by using [[RegisterForSingleUpdate - Form|RegisterForSingleUpdate]] instead:
* If the script is missing or contains an error, it will never be called again.
* If the script is missing or contains an error, it will never be called again.
* If you modify OnUpdate and reload your game, the old version will be only called once. After that the new version will be the one to be called.
* If you modify OnUpdate and reload your game, the old version will be only called once. After that the new version will be the one called.
* The next call can never happen before the previous one completed.
* The next call can never happen before the previous one completed.
<source lang="papyrus">
<source lang="papyrus">
Line 48: Line 52:
endEvent
endEvent
</source>
</source>
It may also be wise to add a handler for [[OnPlayerLoadGame - Actor|OnPlayerLoadGame]]. That way, if OnUpdate previously contained an error and is no longer fired as a result, it will resume once the game is reloaded, hopefully with a modified version that fixes the problem. Note that this event is only fired on the player actor, on the ActiveMagicEffects put on the player and on ReferenceAliases that reference the player.
It may also be wise to add a handler for [[OnPlayerLoadGame - Actor|OnPlayerLoadGame]]. That way, if OnUpdate previously contained an error and is no longer fired as a result, it will resume once the game is reloaded, hopefully with a modified version that fixes the problem. Note that this event is only fired on the player actor, on the ActiveMagicEffects put on the player and on the ReferenceAliases that reference the player.
<source lang="papyrus">
<source lang="papyrus">
Event OnPlayerLoadGame()
Event OnPlayerLoadGame()
Line 54: Line 58:
EndEvent
EndEvent
</source>
</source>
== Notes ==
*Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
*Subsequent calls to RegisterForUpdate will override previous ones - i.e. calling it back to back will result in updates at the second call's interval, but not the first. It does not interfere with updates registered via RegisterForSingleUpdate.
*If you find yourself doing this:
<source lang="papyrus">
Event OnUpdate()
    UnregisterForUpdate()
    ; Do some stuff
endEvent
</source>
Then you should use [[RegisterForSingleUpdate - Form|RegisterForSingleUpdate]] instead


== See Also ==
== See Also ==
Anonymous user

Navigation menu