Advertisement
Bjornir90

Quarry

Jun 25th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. DescentMax = 55
  2. length = 4
  3. width = 4
  4. LeftOrRight = 1
  5.  
  6.  
  7. function log(msg)
  8.     file = fs.open("quarry.log", "a")
  9.     file.write(msg)
  10.     file.close()
  11. end
  12.  
  13. function fw(blocks)
  14.     for i=1, blocks do
  15.         if turtle.detect() then
  16.             turtle.dig()
  17.             log("Dig a block while going forward\n")
  18.         end
  19.         turtle.forward()
  20.     end
  21.     print("Gone forward\n")
  22. end
  23.  
  24. function dw(blocks)
  25.     for i=1, blocks do
  26.         if turtle.detectDown() then
  27.             turtle.digDown()
  28.             log("Dig a block while going down\n")
  29.         end
  30.         turtle.down()
  31.     end
  32.     print("Gone down\n")
  33. end
  34.  
  35. function up(blocks)
  36.     for i=1, blocks do
  37.         if turtle.detectUp() then
  38.             turtle.digUp()
  39.             log("Dig a block while going up\n")
  40.         end
  41.         turtle.up()
  42.     end
  43.     print("Gone up\n")
  44. end
  45.  
  46. fw(width)
  47. for u=0, DescentMax do
  48.     for x=1, length do
  49.         print(LeftOrRight.."\n")
  50.         turn = LeftOrRight%2
  51.         print(turn.."\n")
  52.         if turn == 0 then
  53.             turtle.turnLeft()
  54.             fw(1)
  55.             turtle.turnLeft()
  56.             print("Turn left")
  57.         else
  58.             turtle.turnRight()
  59.             fw(1)
  60.             turtle.turnRight()
  61.             print("Turn right")
  62.         end
  63.         fw(width)
  64.         LeftOrRight = LeftOrRight+1
  65.     end
  66.     dw(1)
  67.     if turn == 1 then
  68.         turtle.turnLeft()
  69.         fw(1)
  70.         turtle.turnRight()
  71.     else
  72.         turtle.turnRight()
  73.         fw(1)
  74.         turtle.turnLeft()
  75.     end
  76.     LeftOrRight = LeftOrRight+1
  77.     for slot=1, 16 do
  78.         turtle.select(slot)
  79.         items = turtle.getItemDetail()
  80.         if items then
  81.             if items.name == "minecraft:dirt" or items.name == "minecraft:sand" then
  82.                 turtle.drop()
  83.             end
  84.             if turtle.getItemCount(15) > 1 then
  85.                 if items.name == "minecraft:cobblestone" then
  86.                     turtle.drop()
  87.                     turtle.select(15)
  88.                     turtle.transferTo(slot)
  89.                     turtle.select(slot)
  90.                 end
  91.             end
  92.         end
  93.     end
  94.     turtle.select(1)
  95.     print("Current level :"..u)
  96. end
  97. turtle.turnRight()
  98. turtle.turnRight()
  99. fw(width)
  100. up(DescentMax+1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement