Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local commands = {
- collect = function()
- modem.broadcast(port, "ping")
- print("Collecting devices...")
- local function registerDevice(signal, _, remoteAddress, _, _, payload)
- print(remoteAddress)
- devices.insert(remoteAddress)
- print(devices)
- end
- event.listen("modem_message", registerDevice)
- event.timer(5, function()
- event.ignore("modem_message", registerDevice)
- event.push("command_executed")
- print(#devices .. " devices found!")
- end)
- end
- }
- while true do
- local input = io.read()
- if input == "quit" or input == "q" then quit() end
- if commands[input] == nil then
- print("Command not found!")
- else
- pcall(commands[input])
- event.pull("command_executed")
- print("")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement