|
函数名 |
setTimer(id,time,function) |
|
函数介绍 |
方法名称:启动一个定时器,定时器内容执行完才会返回继续
time:整数类型,定时器启动时间间隔,单位毫秒。如2000,启动定时器后每过2秒执行定时器。需要停止该定时器时此值设为<=0的值即可 function:函数类型,定时执行的函数名 |
|
函数例子 |
--定时执行的函数 function timerFun() print("定时启动函数内") sleep(2000) end
setTimer(1,1000,timerFun)
local 时间1 = os.time() while true do sleep(500) print("时间:"..os.time()) if os.time() > 时间1 + 5 then --停止定时器 setTimer(1,0) end end |