GRxRedZero

Untitled

Apr 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. --[[
  2. ATS - Advanced Timing System
  3. by SoniEx2
  4. --]]
  5. local function _round(_i)
  6. _i = _i * 20;
  7. local x = math.floor(_i+.5)
  8. return x / 20, x
  9. end
  10.  
  11. -- custom "working" sleep (can sleep 4-12 ticks without sleeping an extra tick)
  12. local function sleepspecial(i)
  13. for _=1, i do
  14. sleep(0.05)
  15. end
  16. end
  17.  
  18. function makesleeper()
  19. local total = 0
  20. local slept = 0
  21. local function wait(_sleep)
  22. if _sleep <= 0 then return end
  23. total = total + _sleep
  24. local f, i = _round(total - slept)
  25. slept = slept + f
  26. sleepspecial(i)
  27. end
  28. return wait
  29. end
Add Comment
Please, Sign In to add comment