Advertisement
Guest User

startup.lua

a guest
Nov 10th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local m = peripheral.find "modem"
  2. local o = peripheral.find "monitor"
  3.  
  4. o.setTextScale(0.5)
  5.  
  6. m.open(31415)
  7.  
  8. term.redirect(o)
  9.  
  10. local function ignore(c, rc)
  11.     --print(c, rc)
  12.     local i =
  13.         c == 666 or c == 999 or rc == 999
  14.    
  15.     return i
  16. end
  17.  
  18. while true do
  19.     local e = { os.pullEvent "modem_message" }
  20.     local msg = e[5]
  21.    
  22.     --print(msg.origin)
  23.  
  24. --print(msg.type)
  25.     if msg.type == "position fix" and not ignore(msg.channel, msg.replyChannel) then
  26.         local p = msg.position
  27.         print("@", p.x, p.y, p.z)    
  28.     elseif msg.origin == "VLA by Anavrins" and not ignore(msg.senderChannel, msg.replyChannel) then
  29.         print(tostring(msg.senderChannel) .. " \16 " .. tostring(msg.replyChannel) .. " | " .. tostring(msg.senderDistance))
  30.         local ok, err = pcall(textutils.serialise, msg.message)
  31.         if not ok then print "[UNSERIALIZABLE]"
  32.         else print(err) end
  33.     end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement