Advertisement
adamg765

Scale2

Jan 10th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. local args = { ... }
  2. local top = 46
  3. local bottom = 42
  4. local width = 66
  5.  
  6. local function refuel()
  7. if turtle.getFuelLevel() == 0 then
  8. local prev = turtle.getSelectedSlot()
  9. turtle.select(1)
  10. if not turtle.refuel(1) then
  11. print('Need more fuel')
  12. while not turtle.refuel(1) do
  13. sleep(1)
  14. end
  15. end
  16. turtle.select(prev)
  17. end
  18. end
  19.  
  20. local function advance()
  21. if turtle.getSelectedSlot() == 16 then
  22. print('Need more materials')
  23. local empty = True
  24. while empty do
  25. for i=11, 16, 1 do
  26. if turtle.getItemCount(16) > 0 then
  27. empty = False
  28. turtle.select(9)
  29. end
  30. sleep(1)
  31. end
  32. end
  33. else
  34. turtle.select(turtle.getSelectedSlot() + 1)
  35. end
  36. end
  37.  
  38. local function replace()
  39. while turtle.detect() do
  40. turtle.dig()
  41. sleep(.5)
  42. end
  43. local data = turtle.getItemDetail()
  44. while turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= 'minecraft:stone' do
  45. advance()
  46. end
  47. turtle.place()
  48.  
  49. end
  50.  
  51. local function returnToFloor()
  52. turtle.turnRight()
  53. turtle.forward()
  54. turtle.turnLeft()
  55. end
  56.  
  57. turtle.select(11)
  58. for i = 1, width, 1 do
  59. local success, data = turtle.inspect()
  60. if success then
  61. if data.name ~= 'minecraft:stone' then
  62. replace()
  63. end
  64. else
  65. replace()
  66. end
  67. for j = 1, top-bottom, 1 do
  68. refuel()
  69. if i % 2 == 1 then
  70. while not turtle.up() do
  71. if turtle.detect() then
  72. turtle.digUp()
  73. elseif turtle.attack() then
  74. else
  75. sleep(1)
  76. end
  77. end
  78. else
  79. while not turtle.down() do
  80. if turtle.detect() then
  81. turtle.digDown()
  82. elseif turtle.attack() then
  83. else
  84. sleep(1)
  85. end
  86. end
  87. end
  88. local success, data = turtle.inspect()
  89. if success then
  90. if data.name ~= 'minecraft:stone' then
  91. replace()
  92. end
  93. else
  94. replace()
  95. end
  96. end
  97. returnToFloor()
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement