From c7136a5b2cc9e6da35df23c4f4dfa7d0668e5a28 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 18 May 2012 23:53:02 +0100 Subject: moduleapi, modulemanager: Re-structure module.event_handlers so that the same handler can harmlessly handle multiple events (thanks Zash) --- core/moduleapi.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/moduleapi.lua') diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 44c84de1..96f1d3ea 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -70,7 +70,12 @@ function api:fire_event(...) end function api:hook_object_event(object, event, handler, priority) - self.event_handlers[handler] = { name = event, priority = priority, object = object }; + local handlers = self.event_handlers[event]; + if not handlers then + handlers = {}; + self.event_handlers[event] = handlers; + end + handlers[event] = { handler = handler, priority = priority, object = object }; return object.add_handler(event, handler, priority); end -- cgit v1.2.3