timer||doc135426

September 20, 2022

Format

 Object:timer(time, function, ...) 
  • The class to which the function belongs:Object

Description

Starts a timer and returns a function that stops the timer.


Precautions

  • When the object is destroyed, the remaining timers on the object will be destroyed and will not be executed again
  • The opened timer should be stopped when not in use to avoid wasting performance

Parameters

Variable name type Description
time int time
function function timer execution function
args The timer function carries parameters


Value Returned

type Description
function stop timer function


special usage

usage withWorld.TimerSame.


Code Samples

local closeTimer = object:timer(20, function ()
    print("todo")
end)