Timer.Create

From Nomad DB

Creates a Timer, which executes a callback after the time has elapsed. The timer can also function as an interval, meaning that the callback is invoked multiple times or indefinitely. This uses CDominoDelayManager internally and the internal game time. The timer also pauses when the game is paused.

If you wish to create a simple timer, which is executed only once and is unnamed, the function timer.Simple can be used.

Syntax

timer.Create(name, duration, amount, callback[, ...])
  • name: string (Unique name of the timer)
  • duration: number (in seconds)
  • amount: number (Amount of repetitions)
  • callback: function (to invoke after the timer elapsed)
  • [...]: varargs (any amount of parameters that should be passed to the callback)
    • function call: callback([...])
  • Returns: Timer instance (can be used with timer.Remove)

Example

Creates a Timer "MyTimer" which prints "This is text" twice (after 5 seconds each).

timer.Create("MyTimer", 5, 2, function(text)
	print(text)
end, "This is text")

Related Pages