Advertisement
ComputerMan123

Jam

Dec 3rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. local modem = peripheral.find("modem", function(name, obj) return obj.isWireless() end)
  2. if not modem then
  3. error("No wireless modem detected", 0)
  4. end
  5. local close = false
  6. if not modem.isOpen(gps.CHANNEL_GPS) then
  7. modem.open(gps.CHANNEL_GPS)
  8. close = true
  9. end
  10.  
  11. while true do
  12. local e, _, recvChannel, sendChannel, msg = os.pullEventRaw()
  13. if e == "modem_message" and recvChannel == gps.CHANNEL_GPS and msg == "PING" then
  14. modem.transmit(sendChannel, gps.CHANNEL_GPS, {{}, {}, {}})
  15. print("Jam ID: " .. (tostring(sendChannel) or "[ERR]"))
  16. elseif e == "terminate" then
  17. if close then
  18. modem.close(gps.CHANNEL_GPS)
  19. end
  20. return
  21. end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement