Advertisement
Guest User

Event

a guest
Mar 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local module = {
  2.     connections = {}   
  3.     }
  4. function module:connect(func)
  5.     local id = tostring(func)
  6.     module.connections[id] = func
  7.    
  8.     local connectionobj = {}
  9.    
  10.     function connectionobj:Disconnect()
  11.         module.connection[id] = nil
  12.     end
  13.    
  14.     return connectionobj
  15.    
  16. end
  17.  
  18. function invoke(...)
  19.     print"Invoke Running"
  20.     for id, func in pairs(module.connections) do
  21.         print(" - Running "..id.."'s function!")
  22.         local function run(...) func(...) end
  23.         coroutine.resume(coroutine.create(run),...)
  24.     end
  25.     print" Invoke Done!"
  26. end
  27.  
  28. return module, invoke
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement