Advertisement
Shaka01

turtle Remote Receiver

Mar 18th, 2023 (edited)
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. rednet.open("left")
  2.  
  3. function findItem()
  4.     for i = 1, 16 do
  5.         if turtle.getItemCount(i) > 0 then
  6.             turtle.select(i)
  7.             break
  8.         end
  9.     end
  10. end
  11.  
  12. function receiveRednetMessage()
  13.     turtle.select(9)
  14.     if message == "top" then
  15.       repeat turtle.digUp() turtle.attackUp() until turtle.up()
  16.     elseif message == "bottom" then
  17.       repeat turtle.digDown() turtle.attackDown() until turtle.down()
  18.     elseif message == "left" then
  19.       turtle.turnLeft()
  20.     elseif message == "right" then
  21.       turtle.turnRight()
  22.     elseif message == "front" then
  23.       turtle.back()
  24.     elseif message == "back" then
  25.       repeat turtle.dig() turtle.attack() until turtle.forward()
  26.       if protocol == "build" then
  27.         findItem()
  28.         if turtle.compareDown() == false then
  29.             repeat turtle.digDown() until turtle.placeDown()
  30.         end
  31.       end
  32.     end
  33.     rednet.broadcast("yo", "moveConfirm")
  34. end
  35.  
  36. while true do
  37. senderId, message, protocol = rednet.receive()
  38. receiveRednetMessage()
  39. end
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement