Timer

Calls a function after a given time.

Constructors

Timer ( number time, boolean repeat optional, function callback )

Creates a Timer.

-- prints "2 seconds" each 2 seconds
local myTimer = Timer(2.0, true, function()
  print("2 seconds")
end)

local callback = function()
  Player.Velocity.Y = 50
end
-- after 5 seconds the Player will jump
local myTimer2 = Timer(5.0, callback)

Functions

nil Cancel ( )

Cancels the Timer.

nil Pause ( )

Stops the Timer until Resume is used.

nil Reset ( )

Resets the Timer.

nil Resume ( )

Starts the Timer after a Pause.

myTimer = Timer(10, function() print("Done") end)
myTimer:Pause()

-- later in the script
myTimer:Resume()

Properties

Time remaining before the function is called.

Time since the start of the Timer.