Advertisement
Risk_exe

Untitled

Apr 13th, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 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. position.x, position.y, 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.  
  50. if position.y < 22 then
  51. Redstone_pulse();
  52. Up();
  53. sleep(5);
  54. Wait_for_minions();
  55. else
  56. Break_minions();
  57. end
  58.  
  59. end
  60.  
  61. function Break_minions()
  62. for i=1, 4, 1 do
  63. turtle.dig();
  64. turtle.turnRight();
  65. end
  66. Ascend();
  67. end
  68.  
  69. function Descend()
  70. while position.y > 8 do
  71. Down();
  72. end
  73. end
  74.  
  75. function Ascend()
  76. while position.y < start_point.y do
  77. Up();
  78. end
  79. end
  80.  
  81. function Populate_position()
  82. --[[ Terrible code. ]]
  83. -- position.y = 100;
  84. -- This function might be obsolete.
  85. end
  86.  
  87.  
  88. function Down()
  89. if turtle.detectDown() then
  90. turtle.digDown();
  91. end
  92. turtle.down();
  93. position.y = position.y - 1;
  94. end
  95.  
  96. function Up()
  97. if turtle.detectUp() then
  98. turtle.digUp()
  99. end
  100. turtle.up()
  101. position.y = position.y + 1;
  102. end
  103.  
  104. function Forward()
  105. if turtle.detect() then
  106. turtle.dig();
  107. end
  108. turtle.forward()
  109. end
  110.  
  111. function Redstone_pulse()
  112. redstone.setOutput('front', true);
  113. redstone.setOutput('back', true);
  114. redstone.setOutput('left', true);
  115. redstone.setOutput('right', true);
  116. sleep(0.5);
  117. redstone.setOutput('front', false);
  118. redstone.setOutput('back', false);
  119. redstone.setOutput('left', false);
  120. redstone.setOutput('right', false);
  121. end
  122.  
  123. print(start_point);
  124. print(position.hi);
  125. local lowest_level = 8;
  126. local highest_level = 22;
  127.  
  128. --[[ turtle.refuel();
  129. turtle.select() ]]
  130. function Init()
  131. turtle.select(1);
  132. Populate_position();
  133. Descend()
  134. Deploy_minions();
  135. Excavate();
  136. Redstone_pulse();
  137. sleep(8);
  138. Wait_for_minions();
  139. end
  140.  
  141. if !(position.z == nil) then
  142. Init();
  143. else
  144. print("must pass coords to turtle");
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement