OnTimer - ScriptObject

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search

Member of: ScriptObject Script

Event called once a real-time timer started on a script expires. This event will not be sent if the game is in menu mode.

Syntax[edit | edit source]

Event OnTimer(int aiTimerID)

Parameters[edit | edit source]

  • aiTimerID: The ID number of the timer which just expired.

Example[edit | edit source]

int myCoolTimerID = 10 ; Give our timer an ID we can remember

Function SomeFunction()                
  StartTimer(5, myCoolTimerID) ; Create the timer with a 5 second duration
EndFunction
	
Event OnTimer(int aiTimerID)		
  If aiTimerID == myCoolTimerID ; The five second timer we started just expired
    Debug.Trace("Timer ended! Do some cool stuff now...")
    ; If we wanted to have the timer start over, we could now do StartTimer again...
  EndIf
EndEvent

Notes[edit | edit source]

  • Aliases and quests will automatically cancel all timers when the quest stops. Active magic effects will automatically cancel all timers when they are removed.
  • This event is not relayed to any other script on the same form, or aliases or magic effects on that form.
  • The time will be affected by the global time modifier.
    • For example, if global time is slowed because the player is in VATS selection or on Jet, timer events will be slowed accordingly.
    • CAUTION: During VATS playback, parts of the game are slowed at different rates. Timer events do not accommodate this, and will run at the player's modified speed, even if other elements of the game (Mysterious Stranger, enemies, world animations) are moving at different modified speeds. This typically means that you will get the event sooner than you expected. It's not an issue for most scripts.
      • However, if you do need to detect and react to OnTimer events differently during VATS playback, you can use IsVATSPlaybackActive to detect this state.

See Also[edit | edit source]