Barnet

ats.lua

Jun 9th, 2021 (edited)
5,800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 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) for _ = 1, i do sleep(0.05) end end
  13.  
  14. function makesleeper()
  15.     local total = 0
  16.     local slept = 0
  17.     local function wait(_sleep)
  18.         if _sleep <= 0 then return end
  19.         total = total + _sleep
  20.         local f, i = _round(total - slept)
  21.         slept = slept + f
  22.         sleepspecial(i)
  23.     end
  24.     return wait
  25. end
  26.  
Add Comment
Please, Sign In to add comment