aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--events.lua4
-rw-r--r--init.lua13
2 files changed, 11 insertions, 6 deletions
diff --git a/events.lua b/events.lua
index 4796973..aa645ea 100644
--- a/events.lua
+++ b/events.lua
@@ -18,13 +18,13 @@ local EventTargetPrototype = {}
function EventTargetPrototype:dispatchEvent(event)
event.target = self
- local callback = self["on" + event.type]
+ local callback = self["on" .. event.type]
if callback then
callback(event)
end
- local listeners = self.__eventListeners[type]
+ local listeners = self.__eventListeners[event.type]
if listeners then
for i, callback in ipairs(listeners) do
diff --git a/init.lua b/init.lua
index b5cb92e..8449a0f 100644
--- a/init.lua
+++ b/init.lua
@@ -1,4 +1,6 @@
-lua_async = {}
+lua_async = {
+ poll_functions = {},
+}
function lua_async.clock()
return lua_async.socket and lua_async.socket.gettime() or os.clock()
@@ -9,11 +11,14 @@ function lua_async.step(dtime)
lua_async.timeouts.step(dtime)
lua_async.intervals.step(dtime)
- -- pending callbacks phase is done by minetest
+ -- pending callbacks phase is obsolete
-- idle & prepare phase are obsolete
- -- poll phase is obsolete
+ -- poll phase
+ for func in pairs(lua_async.poll_functions) do
+ func()
+ end
-- check phase
lua_async.immediates.step(dtime)
@@ -36,6 +41,6 @@ return function(path, no_socket)
"limiting",
"events",
} do
- dofile(path .. f .. ".lua")
+ dofile(path .. "/" .. f .. ".lua")
end
end