Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function detectModem()
- for _,side in ipairs(rs.getSides()) do
- if peripheral.isPresent(side) then
- if peripheral.getType(side) == "modem" then
- rednet.open(side)
- return side
- end
- end
- end
- return false
- end
- local modem = detectModem()
- local event,param1,param2,param3
- local x,y = 0,0
- if modem == false then
- print("No modem found!")
- else
- rednet.open(modem)
- end
- term.clear()
- term.setCursorPos(1,2)
- while true do
- x,y = term.getCursorPos()
- term.setCursorPos(1,1)
- write("Press [SPACE] key to stop!")
- term.setCursorPos(x,y)
- event, param1, param2, param3 = os.pullEvent()
- if event == "rednet_message" then
- print("Rednet message: "..param2)
- elseif event == "key" and param1 == 57 then
- break
- end
- end
- rednet.close(modem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement