Advertisement
Risk_exe

Untitled

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