]> git.lizzy.rs Git - lua_async.git/commitdiff
Add lua_async.run
authorElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 6 Aug 2021 17:38:39 +0000 (19:38 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 6 Aug 2021 17:38:39 +0000 (19:38 +0200)
util.lua

index c4067f11f36eb6fe92c66f5fa0fad6e4f2ad0e63..b5c70436806a2d1cccc2af6af0c2bc404acd7ef4 100644 (file)
--- a/util.lua
+++ b/util.lua
@@ -11,3 +11,15 @@ function lua_async.sleep(ms)
                setTimeout(resolve, ms)
        end))
 end
+
+function lua_async.run()
+       local last_time = os.clock()
+
+       while true do
+               local current_time = os.clock()
+               local dtime = current_time - last_time
+               last_time = current_time
+
+               lua_async.step(dtime)
+       end
+end