Crunchy_Nut

Miner Turtle Program

Jun 1st, 2020
749
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sides = rs.getSides()
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4.  
  5. for i = 1, #sides do
  6.     side = sides[i]
  7.     if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
  8.         rednet.open(side)
  9.         break
  10.     end
  11. end
  12.  
  13. while(true) do
  14.     print("Waiting for command..")
  15.     id, msg = rednet.receive("coms_turtles_miner")
  16.     print("Received message: " .. msg)
  17.  
  18.     if msg == "UPDATE" then
  19.         shell.run("updater false miner")
  20.     elseif msg == "FWD" then
  21.         turtle.forward()
  22.         rednet.broadcast("MOVED_FWD", "status_turtles_miner")
  23.     elseif msg == "BACK" then
  24.         turtle.back()
  25.         rednet.broadcast("MOVED_BACK", "status_turtles_miner")
  26.     elseif msg == "PLACE" then
  27.         turtle.place()
  28.         rednet.broadcast("PLACED", "status_turtles_miner")
  29.     elseif msg == "BREAK" then
  30.         turtle.dig()
  31.         rednet.broadcast("BROKE", "status_turtles_miner")
  32.     end
  33. end
RAW Paste Data