Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EventQueue = {
- Create = function (name)
- local events = {}
- local callbacks = {}
- EventQueue["on"..name] = {
- Connect = function (cb)
- callbacks[cb] = cb
- end,
- Disconnect = function (cb)
- callbacks[cb] = nil
- end,
- DebugTimer = function (enabled)
- -- implement this
- end,
- Queue = function (...)
- table.insert(events, {...})
- end,
- Signal = function (...)
- local e = {...}
- for i = 1, #callbacks do
- callbacks[i](unpack(e))
- end
- end,
- Emit = function ()
- while #events > 0 do
- local e = events.remove(events, 1)
- for i = 1, #callbacks do
- callbacks[i](unpack(e))
- end
- end
- end,
- ClearEvents = function ()
- events = {}
- end,
- }
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement