aboutsummaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-08-06 19:38:39 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-08-06 19:38:39 +0200
commitc3909348044e26d642e4c7f196eb27f1f6255eda (patch)
treecd7069a691432c92c1ceba4164fed3716066860a /util.lua
parenta2770298f040307f8dd59c7a88d7e40d37faec14 (diff)
downloadlua_async-c3909348044e26d642e4c7f196eb27f1f6255eda.tar.xz
Add lua_async.run
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/util.lua b/util.lua
index c4067f1..b5c7043 100644
--- 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