Barnet

Minecraft Turtle: DigCuboid

Apr 26th, 2016 (edited)
415
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -----------Written by Barnet-----------
  2.  
  3. function Eject()
  4.   if EjectCDG == true then
  5.     if turtle.getItemCount(16) ~= 0 then
  6.       j = 1
  7.       while j < 17 do
  8.         turtle.select(j)
  9.         j=j+1
  10.         if turtle.getItemCount() ~= 0 then
  11.           Thing = turtle.getItemDetail().name
  12.           if Thing == "minecraft:cobblestone" or Thing == "minecraft:dirt" or Thing == "minecraft:gravel" then
  13.             turtle.drop()
  14.           end
  15.         end
  16.         if j == 17 then
  17.           turtle.select(1)
  18.         end
  19.       end
  20.     end
  21.   end
  22. end
  23.  
  24. function Dig()
  25.   while turtle.forward() == false do
  26.     if turtle.detect() == true then
  27.       turtle.dig()
  28.     else
  29.       turtle.attack()
  30.     end
  31.   end
  32.   Eject()
  33. end
  34.  
  35. function DigUp()
  36.   while turtle.up() == false do
  37.     if turtle.detectUp() == true then
  38.       turtle.digUp()
  39.     else
  40.       turtle.attackUp()
  41.     end
  42.   end
  43.   Eject()
  44. end
  45.  
  46. function DigDown()
  47.   while turtle.down() == false do
  48.     if turtle.detectDown() == true then
  49.       turtle.digDown()
  50.     else
  51.       turtle.attackDown()
  52.     end
  53.   end
  54.   Eject()
  55. end
  56.  
  57.  
  58. function DigY(y)
  59.   u=1
  60.   while u<y do
  61.     DigUp()
  62.     u=u+1
  63.   end
  64.   Dig()
  65.   u=1
  66.   while u<y do
  67.     DigDown()
  68.     u=u+1
  69.   end
  70.   Dig()
  71. end  
  72.  
  73. function DigX(x,y)
  74.   i=0,5
  75.   while i<x/2 do
  76.     DigY(y)
  77.     i=i+1
  78.   end
  79. end
  80.  
  81. function DigZ(x,y,z)
  82.   p=0
  83.   while p<z/2 do
  84.     DigX(x,y)
  85.     turtle.turnRight()
  86.     Dig()
  87.     turtle.turnRight()
  88.     Dig()
  89.     DigX(x,y)
  90.     turtle.turnLeft()
  91.     Dig()
  92.     turtle.turnLeft()
  93.     Dig()
  94.     p=p+1
  95.   end
  96. end
  97.  
  98.  
  99.  
  100. print()
  101. print("Dig a Cuboid")
  102. print("---------------------------------------")
  103. write("Height: ")
  104. y = tonumber(read())
  105. write("Length: ")
  106. x = tonumber(read())
  107. write("Width: ")
  108. z = tonumber(read())
  109. print("Eject Cobblestone, Dirt and Gravel? (Yes/No)")
  110. Asking = true
  111. while Asking == true do
  112.   I = read()
  113.   if I == "Yes" or I == "yes" then
  114.     EjectCDG = true
  115.     Asking = false
  116.   elseif I == "No" or I == "no" then
  117.     EjectCDG = false
  118.     Asking = false
  119.   else
  120.     print("Please answer with 'Yes' or 'No'.")
  121.   end
  122. end
  123. print("Digging Cuboid...")
  124. DigZ(x,y,z)
  125. print("Done!")
RAW Paste Data