CallWhile
A function added by the New Vegas Script Extender version 6.1.
Contents
Description
Executes a User Defined Function or an inline Lambda script each frame while specified condition UDF (or a Lambda) returns true. If it returns false, then the handler will never be re-evaluated again, unless it is reset by another call to CallWhile.
Every queued call is removed when loading the game (GetGameLoaded), so they may need to be reset during then.
- NOTE: This means that callbacks created using this function are NOT savebaked, which could potentially cause bugs if a callback was expected to keep running after saving and reloading a save while the callback was running.
Runs in both GameMode and MenuMode, unless DontRunInMenuMode and/or DontRunInGameMode flags are enabled (see below). Will also run while paused (meaning while main menu / pause menu / console menu MenuModes are open) unless DontRunWhilePaused is enabled.
The following features have been added starting from xNVSE 6.2.6.
flags is a bitmask, whose bits toggle on/off the following features:
PassArgsToTheCalledFunction = 1 (bit #0) - xNVSE 6.2.6 PassArgsToTheConditionFunction = 2 (bit #1) - xNVSE 6.2.6 DontRunInMenuMode = 4 (bit #2) - xNVSE 6.2.8 DontRunInGameMode = 8 (bit #3) - xNVSE 6.2.8 DontRunWhilePaused = 16 (bit #4) - xNVSE 6.3.0
For example, if flags = 0, then none of these features are on. If flags = 0b11 (Binary Notation, or 3 in decimal), then the first two are on. By default, all flags are off (flags = 0).
Arguments can be passed like Call to the function. If an arg is an array, then its lifetime will be extended until the callbacks have stopped.
If PassArgsToTheCalledFunction is on, then the Call-like args will be passed to the udf, and if PassArgsToTheConditionFunction is on, they'll be passed to the condition UDF. Both flags can be on at the same time.
Syntax
reference.CallWhile udf:script condition:script flags:int{0} multi:arg(up to 15)
Example
CallWhile ({} => ivar += 1) ({} => ivar < 1000)
Calls left UDF each frame until value of ivar reaches 1000