CallLoop
A function added by the pp NVSE Plugin.
Description
Registers a specified UDF Script in a call loop that will be repeatedly and independently called by the game, with the specified delay between calls. This Functions a lot like SetGameMainLoopCallback, with added functionality. CallLoop can be passed arguments, and can be be removed by returning a 1 with SetFunctionValue.
The function takes two arguments:
- 1. callDelay - if passed a -1 it will un-register the call loop
- 2. script - A UDF script.
If the function is called on a reference (implicitly/explicitly), the UDF script, whenever called, will be called on that same reference (passed as "this"). Otherwise, it will be called on the player (see examples, below).
Syntax
reference.CallLoop callDelay:int script:ref Optional:arguments...
Example
CraigBooneRef.SetGameMainLoopCallback 0 MyCallbackUDF arg1 arg2 arg3
Registers the MyCallbackUDF script to be called every frame on CraigBooneRef. The callback will be auto-removed when loading a game/exiting to the main menu.
CraigBooneRef.SetGameMainLoopCallback -1 MyCallbackUDF
Un-registers the MyCallbackUDF script as a callback.
CallLoop Script
A skeleton script for a callback:
scn MyCallbackUDF ref rCallingRef begin Function {ref arg1, ref arg2, ref arg3} set rCallingRef to GetSelfAlt ; Can also use GetSelf, but it won't work on non-persistent items (code) if rCallingRef.GetDead SetFunctionValue 1 ; will auto remove the call back when the calling reference dies. endif end
See Also
- Auxiliary Variables may be used for CallingRef-specific timers.
- Script-type Base Effects can serve a similar role once casted on an Actor.
- CallWhile
- CallAfterSeconds
- CallForSeconds
- CallFunctionNextFrame