|
|
@ -18,8 +18,8 @@ end |
|
|
|
|
|
|
|
|
|
|
|
-- Waits for a number of seconds |
|
|
|
-- Waits for a number of seconds |
|
|
|
function M.wait(duration) |
|
|
|
function M.wait(duration) |
|
|
|
local t = M.gettime() |
|
|
|
local t = M.time.timeSinceLevelLoad |
|
|
|
while (M.gettime() - t < duration) do |
|
|
|
while (M.time.timeSinceLevelLoad - t < duration) do |
|
|
|
coroutine.yield() |
|
|
|
coroutine.yield() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -27,10 +27,10 @@ end |
|
|
|
-- Waits until the lamda function provided returns true, or the timeout expires. |
|
|
|
-- Waits until the lamda function provided returns true, or the timeout expires. |
|
|
|
-- Returns true if the function succeeded, or false if the timeout expired |
|
|
|
-- Returns true if the function succeeded, or false if the timeout expired |
|
|
|
function M.waitfor(fn, timeoutduration) |
|
|
|
function M.waitfor(fn, timeoutduration) |
|
|
|
local t = M.gettime() |
|
|
|
local t = M.time.timeSinceLevelLoad |
|
|
|
while (not fn()) do |
|
|
|
while (not fn()) do |
|
|
|
coroutine.yield() |
|
|
|
coroutine.yield() |
|
|
|
if (M.gettime() - t > timeoutduration) then |
|
|
|
if (M.time.timeSinceLevelLoad - t > timeoutduration) then |
|
|
|
return false |
|
|
|
return false |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|