Created
August 16, 2014 19:13
-
-
Save Anaminus/38d4098a7fdc7d92b0a2 to your computer and use it in GitHub Desktop.
Fast wait
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On client side, this will also wait fairly fast:
local function fast(f, ...)
while f(...) do
game:GetService("RunService").RenderStepped:wait()
end
end