SetGameMainLoopCallback
A function added by the JIP NVSE Plugin.
Description
Registers/removes the specified UDF Script as a callback that will be repeatedly and independently called by the game, with the specified delay between calls.
The function takes four arguments:
- 1. callbackScript - A UDF script. The script should take no arguments (empty braces {}).
- 2. setORremove - (1) Register, or (0) un-register the callback.
- 3. callDelay (optional) - The delay time between calls, in frames. The default is 1 (every frame).
- 4. modeFlag (optional) - A bitmask; enables to restrict the calls to a specific mode, etc. The default is 3.
1 Run on GameMode 2 Run on MenuMode 8 Auto-remove on load game/main menu
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.SetGameMainLoopCallback callbackScript:ref setORremove:1/0 callDelay:int modeFlag:int
Example
CraigBooneRef.SetGameMainLoopCallback MyCallbackUDF 1 30 9
Registers the MyCallbackUDF script to be called every half a second on CraigBooneRef, while in GameMode only. The callback will be auto-removed when loading a game/exiting to the main menu.
CraigBooneRef.SetGameMainLoopCallback MyCallbackUDF 0
Un-registers the MyCallbackUDF script as a callback.
SetGameMainLoopCallback MyCallbackUDF 1
Registers the MyCallbackUDF script to be called every frame on the Player, while in either GameMode or MenuMode.
SetGameMainLoopCallback MyCallbackUDF 0
Un-registers the MyCallbackUDF script as a callback.
Callback Script
A skeleton script for a callback:
scn MyCallbackUDF ref rCallingRef begin Function {} set rCallingRef to GetSelfAlt ; Can also use GetSelf, but it won't work on non-persistent items (code) 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