straightforward signal and slots system for lua events

This commit is contained in:
Eduardo Bart
2011-08-29 16:35:58 -03:00
parent f41fd0576c
commit f05c048f6d
5 changed files with 42 additions and 13 deletions

View File

@@ -10,4 +10,17 @@ function createEnvironment()
local env = { }
setmetatable(env, { __index = _G} )
return env
end
end
function connect(object, signalsAndSlots)
for signal,slot in pairs(signalsAndSlots) do
if not object[signal] then
object[signal] = slot
elseif type(object[signal]) == 'function' then
object[signal] = { object[signal], slot }
elseif type(signal) == 'table' then
table.insert(object[signal], slot)
else
end
end
end