Advertisement
SavageCore

Untitled

Apr 21st, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. local tArgs = {...}
  2. local length = tonumber(tArgs[1])
  3. local width = tArgs[2]
  4. local enderchest = false
  5. local torch = turtle.getItemCount(1)
  6. local chests = turtle.getItemCount(2)
  7. local dist = 0
  8.  
  9. if length ~= nil then
  10. function dump()
  11. if turtle.getItemCount(16)>0 then
  12. turtle.digDown()
  13. turtle.select(2)
  14. turtle.placeDown()
  15. for slot = 4,16,1 do
  16. turtle.select(slot)
  17. turtle.dropDown()
  18. end
  19. if enderchest then
  20. turtle.select(2)
  21. turtle.digDown()
  22. else
  23. chests = chests - 1
  24. end
  25. end
  26. end
  27.  
  28. function digforw()
  29. if turtle.detect() then
  30. turtle.dig()
  31. end
  32. turtle.forward()
  33. dump()
  34. turtle.digUp()
  35. dump()
  36. dist = dist + 1
  37. end
  38.  
  39. function home()
  40. turtle.turnLeft()
  41. turtle.turnLeft()
  42. if turtle.detectUp() then
  43. turtle.digUp()
  44. end
  45. turtle.up()
  46. for i=1,dist,1 do
  47. turtle.forward()
  48. end
  49. turtle.down()
  50. if torch==0 then
  51. print("Ran out of torches.")
  52. elseif chests==0 then
  53. print("Ran out of chests.")
  54. else
  55. print("Ran out of fuel.")
  56. end
  57. turtle.turnLeft()
  58. turtle.turnLeft()
  59. end
  60.  
  61. function light()
  62. turtle.turnLeft()
  63. turtle.turnLeft()
  64. turtle.select(1)
  65. turtle.place()
  66. turtle.turnLeft()
  67. turtle.turnLeft()
  68. torch = torch - 1
  69. end
  70.  
  71. local retdist = 0
  72. local fuel = turtle.getFuelLevel()
  73. function run()
  74. while (torch>0) and (chests>0) and (fuel>retdist) and (dist < length) do
  75. for i=1,12,1 do
  76. digforw()
  77. end
  78. light()
  79. retdist = dist + 14
  80. fuel = turtle.getFuelLevel()
  81. end
  82. home()
  83. end
  84.  
  85. run()
  86. else
  87. print("Please input length.")
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement