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

前端 未结 19 1424
礼貌的吻别
礼貌的吻别 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:23

    I agree with John on wrapping the sleep function. You could also use this wrapped sleep function to implement a pause function in lua (which would simply sleep then check to see if a certain condition has changed every so often). An alternative is to use hooks.

    I'm not exactly sure what you mean with your third bulletpoint (don't commands usually complete before the next is executed?) but hooks may be able to help with this also.

    See: Question: How can I end a Lua thread cleanly? for an example of using hooks.

提交回复
热议问题