Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- computer (server)
- local component = require("component")
- local modem = component.modem
- local eventName = "modem"
- local event = require("event")
- local port = 9999
- function sendEvent(msg)
- print("sendEvent")
- modem.broadcast(port, msg)
- end
- function waitForEvent()
- print("waitForEvent")
- local _, _, _, _, _, msg = event.pull(eventName)
- return msg
- end
- local i = 1
- while true do
- msg = "sending event " .. i
- sendEvent(msg)
- print(msg)
- i = i +1
- os.sleep(5)
- end
- -- end computer (server)
- -- robot (client)
- local component = require("component")
- local modem = component.modem
- local eventName = "modem"
- local event = require("event")
- local port = 9999
- function sendEvent(msg)
- print("sendEvent")
- modem.broadcast(port, msg)
- end
- function waitForEvent()
- print("waitForEvent")
- local _, _, _, _, _, msg = event.pull(eventName)
- return msg
- end
- print('listening for event...')
- while true do
- result = waitForEvent()
- if (result) then
- print(result)
- else
- print('no result')
- end
- end
- --end robot (client)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement