Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component = require("component")
- event = require("event")
- serialization = require("serialization")
- local config = {}
- function addDeviceEvent(device, eventName)
- if config[device] == nil then
- config[device] = {}
- config[device].events = {}
- end
- if config[device].events == nil then
- table.insert(config[device].events, eventName)
- end
- end
- function eventHandler(event, device, ...)
- local args = {...}
- print("new event: " .. event .. " from device: " .. device)
- addDeviceEvent(device, event)
- for i=1,#args do
- if args[i] ~= nil then
- io.write(" (" .. args[i] .. " ) ")
- end
- end
- print("")
- end
- local stopme = false
- while not stopme do
- local args = { event.pull(math.huge) }
- if args[1] == "interrupted"
- then stopme = true
- else eventHandler(table.unpack(args))
- end
- end
- for i=1,#config do
- print(config[i])
- for j=1,#config[i].events do
- print(config[i].events[j])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement