Advertisement
kyle1320

Untitled

Mar 28th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. tArg = { ... }
  2.  
  3. fwd = function()
  4. refuel()
  5.  
  6. while turtle.forward()==false do
  7. turtle.dig()
  8. end
  9. end
  10.  
  11. down = function()
  12. refuel()
  13.  
  14. while turtle.down()==false do
  15. turtle.digDown()
  16. end
  17. end
  18.  
  19. chooseTurn = function(condition, condition2)
  20. if condition then
  21. turtle.turnRight()
  22. if condition2 then
  23. fwd()
  24. end
  25. turtle.turnRight()
  26.  
  27. else
  28. turtle.turnLeft()
  29. if condition2 then
  30. fwd()
  31. end
  32. turtle.turnLeft()
  33.  
  34. end
  35. end
  36.  
  37. refuel = function()
  38. if turtle.getFuelLevel()<20 then
  39. if turtle.getItemCount(16)==1 then
  40. print("out of fuel!")
  41. exit()
  42. end
  43.  
  44. turtle.select(16)
  45.  
  46. if turtle.refuel(1)==false then
  47. print("problem fueling!")
  48. exit()
  49. end
  50.  
  51. turtle.select(15)
  52. end
  53.  
  54. if turtle.getItemCount(15) == 1 then
  55. print("Out of chests!")
  56. exit()
  57. end
  58.  
  59. if isfull() then
  60. empty()
  61. end
  62. end
  63.  
  64. isfull = function()
  65. local full = true
  66.  
  67. for i=1,14 do
  68. if turtle.getItemCount(i)==0 then
  69. full = false
  70. end
  71. end
  72.  
  73. return full
  74. end
  75.  
  76. empty = function()
  77. turtle.digDown()
  78. turtle.select(15)
  79. turtle.placeUp()
  80. for i=1,14 do
  81. turtle.select(i)
  82. turtle.dropUp()
  83. end
  84. turtle.select(15)
  85. end
  86.  
  87. dig = function(length, width, height)
  88. for i=1,height do
  89. down()
  90.  
  91. for j=1,width-1 do
  92. for k=1,length-1 do
  93. fwd()
  94. end
  95.  
  96. chooseTurn((((width+1)%2)*(i-1)+j)%2==1, true)
  97. end
  98.  
  99. for k=1,length-1 do
  100. fwd()
  101. end
  102.  
  103. turtle.turnRight()
  104. turtle.turnRight()
  105. end
  106. end
  107.  
  108. dig(tArg[1], tArg[2], tArg[3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement