Creating a timer using Lua

前端 未结 6 826
粉色の甜心
粉色の甜心 2020-12-31 13:50

I would like to create a timer using Lua, in a way that I could specify a callback function to be triggered after X seconds have passed.

What would be the best way t

6条回答
  •  借酒劲吻你
    2020-12-31 13:52

    Try lalarm, here: http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/

    Example (based on src/test.lua):

    -- alarm([secs,[func]])
    alarm(1, function() print(2) end); print(1)
    

    Output:

    1
    2
    

提交回复
热议问题