Advertisement
Risk_exe

Untitled

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