Advertisement
Risk_exe

Untitled

Apr 12th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1.  
  2. local position = {
  3. x = 0, y = 0, z = 0
  4. }
  5.  
  6. local start_point = {
  7. x = 0, y = 0, z = 0
  8. }
  9.  
  10.  
  11.  
  12. function Deploy_minions()
  13. clear();
  14. for i=1,4,1 do
  15. turtle.select(i);
  16. turtle.place();
  17. turtle.turnRight();
  18. end
  19. end
  20.  
  21. function Excavate()
  22. local a = peripheral.wrap('front');
  23. local b = peripheral.wrap('left');
  24. local c = peripheral.wrap('back');
  25. local d = peripheral.wrap('right');
  26. a.turnOn(); b.turnOn(); c.turnOn(); d.turnOn();
  27. end
  28.  
  29. function clear()
  30. for i=1,4,1 do
  31. turtle.dig();
  32. turtle.turnRight();
  33. end
  34. end
  35.  
  36. function Wait_for_minions()
  37. while true do
  38. if turtle.inspect() then
  39. turtle.turnRight();
  40. if turtle.inspect() then
  41. turtle.turnRight();
  42. if turtle.inspect() then
  43. turtle.turnRight();
  44. if turtle.inspect() then
  45. turtle.turnRight();
  46. break;
  47. end
  48. end
  49. end
  50. end
  51. end
  52.  
  53. if position.y < 22 then
  54. Redstone_pulse();
  55. Up();
  56. else
  57. Break_minions();
  58. Ascend();
  59. end
  60.  
  61. end
  62.  
  63. function Break_minions()
  64. for i=1, 4, 1 do
  65. turtle.dig();
  66. turtle.turnRight();
  67. end
  68. Ascend();
  69. end
  70.  
  71. function Descend()
  72. while position.y > 8 do
  73. Down();
  74. end
  75. end
  76.  
  77. function Ascend()
  78. while position.y < start_point.y do
  79. Up();
  80. end
  81.  
  82. end
  83.  
  84. function Populate_position()
  85. --[[ Terrible code. ]]
  86. for i,v in ipairs(arg) do
  87. if (i == 1) then
  88. start_point.x = v;
  89. position.x = v;
  90. end
  91. if (i == 2) then
  92. start_point.y = v;
  93. position.y = v;
  94. end
  95. if (i == 3) then
  96. start_point.z = v;
  97. position.z = v;
  98. end
  99. end
  100. end
  101.  
  102.  
  103. function Down()
  104. if turtle.detectDown() then
  105. turtle.digDown();
  106. end
  107. turtle.down();
  108. position.y = position.y - 1;
  109. end
  110.  
  111. function Up()
  112. if turtle.detectUp() then
  113. turtle.digUp()
  114. end
  115. turtle.up()
  116. position.y = position.y + 1;
  117. end
  118.  
  119. function Forward()
  120. if turtle.detect() then
  121. turtle.dig();
  122. end
  123. turtle.forward()
  124. end
  125.  
  126. function Redstone_pulse()
  127. redstone.setOutput('front', true);
  128. redstone.setOutput('back', true);
  129. redstone.setOutput('left', true);
  130. redstone.setOutput('right', true);
  131. sleep(0.5);
  132. redstone.setOutput('front', false);
  133. redstone.setOutput('back', false);
  134. redstone.setOutput('left', false);
  135. redstone.setOutput('right', false);
  136. end
  137.  
  138. print(start_point);
  139. print(position.hi);
  140. local lowest_level = 8;
  141. local highest_level = 22;
  142.  
  143. --[[ turtle.refuel();
  144. turtle.select() ]]
  145. function Init()
  146. Populate_position();
  147. Descend()
  148. Deploy_minions();
  149. Excavate();
  150. Redstone_pulse();
  151. sleep(8);
  152. Wait_for_minions();
  153. end
  154.  
  155. Init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement