smigger22

Untitled

May 9th, 2015
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. function findModem()
  2. for _,s in ipairs(rs.getSides()) do
  3. if peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
  4. return s
  5. end
  6. end
  7. return false
  8. end
  9.  
  10. if pocket then
  11. rednet.open("back")
  12. tArgs = { ... }
  13. if #tArgs ~= 2 then
  14. print("Usage: " .. shell.getRunningProgram() .. " <to> <message>")
  15. else
  16. rednet.broadcast("_FIND")
  17. while true do
  18. id, msg, dis = rednet.receive()
  19. if id == msg then
  20. message = tArgs[2]
  21. to = tArgs[1]
  22. rednet.send(id, { to = to, message = message })
  23. break
  24. end
  25. end
  26. end
  27. else
  28. while true do
  29. rednet.open(findModem())
  30. id, msg, dis = rednet.receive()
  31. if type(msg) == "table" and msg.to and msg.message then
  32. commands.exec("msg " .. msg.to .. " " .. msg.message)
  33. else
  34. if msg == "_FIND" then
  35. rednet.send(id, os.getComputerID())
  36. end
  37. end
  38. end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment