RegisterForUpdate is a function that in almost all cases can be replaced by the safer RegisterForSingleUpdate. A nice feature would be a warning for anyone who uses this function, so they can consider using RegisterForSingleUpdate instead.
Highlights of the issue for RegisterForUpdate from the papyrus wiki, rewritten for simplification:
If a mod is removed, its OnUpdate handler will still be registered and the game engine will continue to try to invoke it.
Even if your mod still exists, you may not exclude the possibility that a bug manifests itself and causes periodic errors. A better behavior if your event handler contains a bug would be to cancel the automatic updates, which is achieved through RegisterForSingleUpdate.
Modifying the OnUpdate handler has no effect: as long as the old handler was registered, it will continue to be used unless you explicitly unregister for updates, then register again.
If the OnUpdate handler takes longer than the interval specified in RegisterForUpdate, the event calls can stack, causing stack dumps, save game bloat, script lag, etc.
Using RegisterForSingleUpdate can avoid all those problems, and is the preferred alternative to RegisterForUpdate for most use cases.
RegisterForUpdate
is a function that in almost all cases can be replaced by the saferRegisterForSingleUpdate
. A nice feature would be a warning for anyone who uses this function, so they can consider usingRegisterForSingleUpdate
instead.Highlights of the issue for
RegisterForUpdate
from the papyrus wiki, rewritten for simplification:OnUpdate
handler takes longer than the interval specified inRegisterForUpdate
, the event calls can stack, causing stack dumps, save game bloat, script lag, etc.Using
RegisterForSingleUpdate
can avoid all those problems, and is the preferred alternative toRegisterForUpdate
for most use cases.