Advertisement
tmkop

turtle scan

May 22nd, 2025
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. local id = 25000 + os.getComputerId()
  2. local modem = peripheral.find("modem") or error("No modem attached", 0)
  3. modem.open(id)
  4. modem.transmit(24999,nil,"Turtle "..os.getComputerId().." has started scanning")
  5.  
  6. repeat
  7.     local x,y,z = gps.locate()
  8.     if not x or not y or not z then error("Cannot connect to GPS",0) end
  9.    
  10.     local down,down_data = turtle.inspectDown()
  11.     local up,up_data = turtle.inspectUp()
  12.     local front,front_data = turtle.inspect()
  13.    
  14.     if down then modem.transmit(id,nil,"X"..x.."Y"..(y-1).."Z"..z.."B"..down_data.name) end
  15.     if up then modem.transmit(id,nil,"X"..x.."Y"..(y+1).."Z"..z.."B"..up_data.name) end
  16.     --modem.transmit(id,nil,"X"..x.."Y"..y.."Z"..z.."B"..turtle.)
  17.    
  18.     event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  19. until channel == id and message == "stop scan"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement