SetGameMainLoopCallback

From GECK
Jump to: navigation, search

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 (1 second = 60 frames). The default is 1 (every frame).
  • 4. modeFlag (optional) - Enables to restrict the calls to a specific mode: (1) GameMode only; (2) MenuMode only; (3) Any mode (default).

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

[help]
reference.SetGameMainLoopCallback callbackScript:ref setORremove:1/0 callDelay:int modeFlag:int

Example

CraigBooneRef.SetGameMainLoopCallback MyCallbackUDF 1 30 1

Registers the MyCallbackUDF script to be called every half a second on CraigBooneRef, while in GameMode only.

CraigBooneRef.SetGameMainLoopCallback MyCallbackUDF 0

Un-registers the MyCallbackUDF script as a callback.


SetGameMainLoopCallback MyCallbackUDF 1

Registers the MyCallbackUDF script to be called every frame (60 times/second) 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 this

	(code)

end

See Also