Xen0Xys

Quarry

Apr 19th, 2021 (edited)
570
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getTurtleMaxMoves()
  2.     return (turtle.getFuelLevel() * 5) / 100
  3. end
  4.  
  5. function getTurtleChestFacing()
  6.     for i = 0, 3, 1
  7.     do
  8.         if turtle.detect() then
  9.             local success, data = turtle.inspect()
  10.             if data.name == "minecraft:chest" then
  11.                 for i = 0, 3 - i, 1
  12.                 do
  13.                     turtle.turnRight()
  14.                 end
  15.                 return i
  16.             end
  17.         end
  18.         turtle.turnRight()
  19.     end
  20.     return -1
  21. end
  22.  
  23. function setupTurtleFacing(chestFacing)
  24.     for i = 0, chestFacing + 2, 1
  25.         turtle.turnRight()
  26.     end
  27. end
  28.  
  29. -- Turtle init
  30. turtle.refuel()
  31. print("Turtle refuel")
  32. setupTurtleFacing(getTurtleChestFacing())
  33. print("Turtle facing set")
  34. -- Variables
  35. spentFuel = 0
  36. -- User variables
  37. print("Enter quarry size:")
  38. quarrySize = io.read("*n")
  39. -- Main programm
  40. while true do
  41.     xMoves = 0
  42.     yMoves = 0
  43.     zMoves = 0
  44.     while spentFuel > getTurtleMaxMoves() + 10 do
  45.         beforeMovingFuel = getTurtleMaxMoves()
  46.         if xMoves < quarrySize then
  47.             xMoves = xMoves + 1
  48.             if turtle.inspect() then
  49.                 turtle.dig()
  50.             end
  51.             turtle.forward()
  52.         else if yMoves < quarrySize then
  53.             yMoves = yMoves + 1
  54.             if turtle.inspect() then
  55.                 turtle.dig()
  56.             end
  57.             turtle.forward()
  58.         end
  59.     end
  60. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×