Skip to content

Instantly share code, notes, and snippets.

@Anaminus
Created August 16, 2014 19:13
Show Gist options
  • Select an option

  • Save Anaminus/38d4098a7fdc7d92b0a2 to your computer and use it in GitHub Desktop.

Select an option

Save Anaminus/38d4098a7fdc7d92b0a2 to your computer and use it in GitHub Desktop.
Fast wait
function fast(f)
local function run()
if f() ~= false then
Spawn(run)
end
end
Spawn(run)
end
local time = 1
local count = 0
local start = tick()
fast(function()
count = count + 1
if tick()-start < time then
return true
else
print(string.format('function ran %d times in %g seconds',count,tick()-start))
return false
end
end)
@Quenty
Copy link

Quenty commented Aug 16, 2014

On client side, this will also wait fairly fast:

local function fast(f, ...)
while f(...) do
game:GetService("RunService").RenderStepped:wait()
end
end

Copy link

ghost commented Aug 16, 2014

Why wouldn't you use wait(0)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment