CallForSeconds
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 until specified amount of seconds have elapsed in-game.
Only runs in GameMode by default, or if runWhen is set to 0. If runWhen is set to 1, will also run in MenuMode. If it is set to 2, will also pause the callback while the main menu / pause menu / console menu MenuModes are open (new in 6.3.0).
Every queued call is removed when loading the game (GetGameLoaded), so they may need to be reset during then.
- NOTE: This means that timers created using this function are NOT savebaked, which could potentially cause bugs if a timer was expected to keep running after saving and reloading a save while the timer was running.
Arguments can be passed like Call to the function (since xNVSE 6.2.6). If an arg is an array, then its lifetime will be extended until the callbacks have stopped.
Syntax
reference.CallForSeconds seconds:float udf:script runWhen:int{0} multi:arg(up to 15)
Or:
reference.CallFor seconds:float udf:script runWhen:int{0} multi:arg(up to 15)
Example with an inline Lambda script
CallForSeconds 10 (begin function {} print "You look so shiftless" end)
Or
CallForSeconds 10 ({} => print "You look so shiftless")
Calls UDF each frame for 10 seconds while in GameMode. See Lambda.
Example with a UDF
scn MyUDF Begin Function { ref rPlayer } print "la la la ", + $rPlayer End
CallForSeconds 10 MyUDF 1 PlayerRef
Notes
- The seconds are not counted in real-life seconds; they are affected by the game's Time Mult (GetGlobalTimeMultiplier).
- The time mult affects the callback even while inside MenuMode.