TheKojent

clear

Jan 31st, 2013
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. --First attempt at excavation program
  2. function dumpInv() --Dumps inventory into ender chest located in slot 1
  3.   turtle.digUp()
  4.   turtle.select(1)
  5.   turtle.placeUp()
  6.   for i = 1,15 do
  7.     i = i + 1
  8.     turtle.dropUp()
  9.   end
  10.   turtle.select(1)
  11.   turtle.digUp()
  12. end
  13.  
  14. function checkInv()
  15.   if turtle.getItemCount(16) ~= 0 then
  16.     dumpInv()
  17.   end
  18. end
  19.  
  20. function digFwd()
  21.   while turtle.forward() == false do
  22.     turtle.dig()
  23.   end
  24. end  
  25.  
  26. function digRow()
  27.   turtle.select(1)
  28.   for l = 1,(x-1) do
  29.     checkInv()
  30.     digFwd()
  31.   end
  32. end
  33.  
  34. --Main function
  35. print("Enter even length")
  36. x = io.read()
  37. x = tonumber(x)
  38. print("Enter even width")
  39. y = io.read()
  40. y = tonumber(y)
  41. print("Enter even depth")
  42. z = io.read()
  43. z = tonumber(z)
  44. fuelreq = x * y * z --Checking fuel level
  45. if turtle.getFuelLevel() < fuelreq then
  46.   print("Not enough fuel...rebooting")
  47.   os.sleep(10)
  48.   os.reboot()
  49. end
  50. for h = 1,z do
  51.   for w = 1,((y/2)-1) do
  52.     digRow()
  53.     turtle.turnRight()
  54.     digFwd()
  55.     turtle.turnRight()
  56.     digRow()
  57.     turtle.turnLeft()
  58.     digFwd()
  59.     turtle.turnLeft()
  60.   end
  61.   digRow()
  62.   turtle.turnRight()
  63.   digFwd()
  64.   turtle.turnRight()
  65.   digRow()
  66.   while turtle.down == false do
  67.     turtle.digDown()
  68.   end
  69.   turtle.turnRight()
  70. end
  71. dumpInv()
Advertisement
Add Comment
Please, Sign In to add comment