dany_ev3

Quarry Turtle

May 17th, 2021 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. function refuel()
  2.   if turtle.getFuelLevel() <= 50 then
  3.     for i = 1, 16 do
  4.       turtle.select(i)
  5.       turtle.refuel()
  6.     end
  7.     turtle.select(1)
  8.   end
  9. end
  10.  
  11. function forward()
  12.   refuel()
  13.   while turtle.detect() do
  14.     turtle.dig()
  15.   end
  16.   turtle.forward()
  17. end
  18.  
  19. function getnvar(question, limit)
  20.   write(question)
  21.   n = read()
  22.   if tonumber(n) then
  23.     n = tonumber(n)
  24.     if n > limit then
  25.       print("Too big!")
  26.       return getnvar(question, limit)
  27.     else
  28.       return n
  29.     end
  30.   else
  31.     print("That's not a number")
  32.     return getnvar(question, limit)
  33.   end
  34. end
  35.  
  36. shell.run("clear")
  37. print("Please put a chest behind me.")
  38. width = getnvar("\nHow wide should I dig? ", 32)
  39. depth = getnvar("\n(To dig to the bottom of the world insert my Y coordinate - 6)\nHow deep should I dig? ", 255)
  40. height = 3
  41. for y = 1, depth do
  42.   turtle.digDown()
  43.   turtle.down()
  44.   for x = 1, width do
  45.     for z = 2, width do
  46.       forward()
  47.     end
  48.     for nz = 2, width do
  49.       turtle.back()
  50.     end
  51.     if x ~= width then
  52.       turtle.turnRight()
  53.       forward()
  54.       turtle.turnLeft()
  55.     end
  56.   end
  57.   turtle.turnLeft()
  58.   for nx = 2, width do
  59.     forward()
  60.   end
  61.   turtle.turnLeft()
  62.   for ny = 1, y do
  63.     turtle.up()
  64.   end
  65.   for slot = 1, 16 do
  66.     turtle.select(slot)
  67.     turtle.drop()
  68.   end
  69.   turtle.select(1)
  70.   turtle.turnLeft()
  71.   turtle.turnLeft()
  72.   if y ~= depth then
  73.     for _y = 1, y do
  74.       turtle.down()
  75.     end
  76.   end
  77. end
  78. print("\n\nDone!")
  79.  
Add Comment
Please, Sign In to add comment