Advertisement
Guest User

robot_planter

a guest
Mar 8th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. local com = require('component')
  2. local inventory_controller = com.inventory_controller
  3. local rob = require('robot')
  4. local term = require('term')
  5.  
  6. local slot = 1
  7. local m = 0 --минуты
  8. local sec = 0
  9. local tree2Num = 0
  10. local tree1 = 0
  11. local tree2 = 0
  12. local time = -9984
  13. local B = 1
  14. local S = 0
  15. local block = 0
  16. local otvet = 0
  17.  
  18. term.clear()
  19. print('======================Planter=====================') --50
  20. print('Сколько деревьев высадить? (в одном ряду)')
  21. tree1 = io.read()
  22. print('Количество рядов: ')
  23. tree2 = io.read()
  24. print('Растояние между деревьев')
  25. S = io.read()
  26. print('Выберите режим')
  27. print('1) Единичная высадка')
  28. print('2) Повторение высадки, через промежуток времени')
  29. otvet = io.read()
  30. if otvet == '2' then
  31. print('Время между высаживаниями (в минутах)')
  32. time = io.read()
  33. time = time*60
  34. end
  35. print('Мне надо '..(tree2*tree1)..' саженца(ов).')
  36. print('Нажмите любую клавишу, что бы начать.')
  37. otvet = io.read()
  38. term.clear()
  39. print('======================Planter=====================')
  40. print('Я работаю')
  41. S = S+1
  42. tree1 = tree1-1
  43. rob.select(1)
  44.  
  45. while true do
  46. for i10 = 1,(((tree1+1)*tree2)/64)-((((tree1+1)*tree2)%64)/64) do
  47. rob.suckDown()
  48. rob.select(slot+1)
  49. end
  50. rob.suckDown(((tree1+1)*tree2)%64)
  51. slot = 1
  52. rob.select(1)
  53. block = 0
  54. rob.swingUp()
  55. rob.up()
  56. rob.swing()
  57. rob.forward()
  58. term.clear()
  59. print('======================Planter=====================')
  60. print('Я работаю')
  61. sec = time-1
  62. for i5 = 1,tree2 do
  63. tree2Num = tree2Num+1
  64. for i2 = 1,tree1 do
  65. rob.swingDown()
  66. rob.select((block/64)-((block%64)/64)+1)
  67. if block/64 == (block/64)-((block%64)/64) then
  68. com.inventory_controller.equip()
  69. end
  70. block = block+1
  71. rob.useDown()
  72. for i1 = 1,S do
  73. rob.swing()
  74. rob.forward()
  75. end
  76.  
  77. end
  78. rob.swingDown()
  79. rob.select((block/64)-((block%64)/64)+1)
  80. if block/64 == (block/64)-((block%64)/64) then
  81. com.inventory_controller.equip()
  82. end
  83. block = block+1
  84. rob.useDown()
  85. if tree2-tree2Num == 0 then
  86. if B == 1 then
  87. rob.turnRight()
  88. rob.swing()
  89. rob.forward()
  90. rob.turnRight()
  91. for i6 = 1,S*(tree1)+1 do
  92. rob.swing()
  93. rob.forward()
  94. end
  95. rob.turnRight()
  96. rob.swing()
  97. rob.forward()
  98. else
  99. rob.swing()
  100. rob.forward()
  101. rob.turnRight()
  102. end
  103. for i8 = 1,S*(tree2-1) do
  104. rob.swing()
  105. rob.forward()
  106. end
  107. rob.turnRight()
  108. rob.swingDown()
  109. rob.down()
  110. elseif B == 1 then
  111. rob.turnRight()
  112. for i3 = 1,S do
  113. rob.swing()
  114. rob.forward()
  115. end
  116. rob.turnRight()
  117. B = 2
  118. else
  119. B = 1
  120. rob.turnLeft()
  121. for i4 = 1,S do
  122. rob.swing()
  123. rob.forward()
  124. end
  125. rob.turnLeft()
  126. end
  127. end
  128. tree2Num = 0
  129. B = 1
  130. term.clear()
  131. slot = 1
  132. rob.turnLeft()
  133. for i11 = 1,16 do
  134. rob.select(slot)
  135. rob.drop()
  136. slot = slot+1
  137. end
  138. com.inventory_controller.equip()
  139. rob.drop()
  140. rob.turnRight()
  141. slot = 1
  142. rob.select(1)
  143. if time == -9984 then
  144. break
  145. else
  146. for i9 = 1,time do
  147. term.clear()
  148. print('======================Planter=====================')
  149. print('Я пойду работать через: '..(sec/60)-((sec%60)/60)..'мин. '..(sec%60)..'сек.')
  150. os.sleep(1)
  151. sec = sec-1
  152. end
  153. rob.select(1)
  154. end
  155. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement