Advertisement
Risk_exe

Untitled

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