erdos/src/async.lua

49 lines
976 B
Lua
Raw Normal View History

2022-02-16 18:53:37 +00:00
ACTIVE = true
function __run()
if love.event then
love.event.pump()
for n, a,b,c,d,e,f in love.event.poll() do
if n == 'quit' or not ACTIVE then
if not love.quit or not love.quit() then
ACTIVE = false
return a or 0
end
end
love.handlers[n](a,b,c,d,e,f)
end
end
local dt = 0
if love.timer
then dt = love.timer.step() or love.timer.getDelta()
end
if love.update then love.update(dt) end
if love.graphics and love.graphics.isActive() then
love.graphics.origin()
love.graphics.clear(0, 0, 0)
if love.draw then love.draw() end
love.graphics.present()
end
if love.timer then love.timer.sleep(0.001) end
end
function await(fn)
while fn() ~= true do
if not ACTIVE then break end
__run()
end
end
function love.run()
if love.timer then love.timer.step() end
if love.getVersion() == 0
then
while ACTIVE do
__run()
end
else return __run
end
end