Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findModem()
- for _,s in ipairs(rs.getSides()) do
- if peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
- return s
- end
- end
- return false
- end
- if pocket then
- rednet.open("back")
- tArgs = { ... }
- if #tArgs ~= 2 then
- print("Usage: " .. shell.getRunningProgram() .. " <to> <message>")
- else
- rednet.broadcast("_FIND")
- while true do
- id, msg, dis = rednet.receive()
- if id == msg then
- message = tArgs[2]
- to = tArgs[1]
- rednet.send(id, { to = to, message = message })
- break
- end
- end
- end
- else
- while true do
- rednet.open(findModem())
- id, msg, dis = rednet.receive()
- if type(msg) == "table" and msg.to and msg.message then
- commands.exec("msg " .. msg.to .. " " .. msg.message)
- else
- if msg == "_FIND" then
- rednet.send(id, os.getComputerID())
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment