Advertisement
goldfiction

delay_mc

Mar 11th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. local function delay(seconds)
  2. -- safe version of 'sleep' - will requeue dropped events
  3. local timer = os.startTimer(seconds)
  4. local q = {}
  5. while true do
  6. local data = {os.pullEvent()}
  7. if data[1] == "timer" and data[2] == timer then
  8. break
  9. else
  10. table.insert(q, data)
  11. end
  12. end
  13. for i,v in ipairs(q) do
  14. os.queueEvent(unpack(v))
  15. end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement