Easiest way to make lua script wait/pause/sleep/block for a few seconds?

前端 未结 19 1240
礼貌的吻别
礼貌的吻别 2020-12-03 00:41

I cant figure out how to get lua to do any common timing tricks, such as

  • sleep - stop all action on thread

  • pause/wait - don\'t go on to the

相关标签:
19条回答
  • 2020-12-03 01:42

    You can do this:

    function Sleep(seconds)
        local endTime = os.time() + seconds
        while os.time() < endTime do
        end
    end
    print("This is printed first!")
    Sleep(5)
    print("This is printed 5 seconds later!")
    
    0 讨论(0)
提交回复
热议问题