Advertisement
pyrater

Pys tree farm

Apr 17th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. local component=require("component")
  2. local robot=require("robot")
  3.  
  4. function treelogic()
  5. logic = robot.compare()
  6. if logic == false then
  7. robot.swing(forward, 10)
  8. robot.swing(up, 10)
  9. moveforward(1)
  10. robot.suck()
  11.  
  12. robot.up()
  13. for i=1,4 do
  14. robot.swing(forward, 10)
  15. robot.suck()
  16. robot.turnLeft()
  17. end
  18.  
  19. robot.up()
  20. for i=1,4 do
  21. robot.swing(forward, 10)
  22. robot.suck()
  23. robot.turnLeft()
  24. end
  25.  
  26. robot.up()
  27. for i=1,4 do
  28. robot.swing(forward, 10)
  29. robot.suck()
  30. robot.turnLeft()
  31. end
  32.  
  33. robot.down()
  34. robot.down()
  35. robot.down()
  36. robot.turnLeft()
  37. moveforward(1)
  38. robot.turnLeft()
  39. moveforward(1)
  40. robot.turnLeft()
  41. moveforward(2)
  42. robot.turnLeft()
  43. moveforward(2)
  44. robot.turnLeft()
  45. moveforward(1)
  46. robot.turnLeft()
  47. robot.suck()
  48. robot.place()
  49. robot.turnAround()
  50. else
  51. robot.suck()
  52. robot.turnLeft()
  53. robot.forward()
  54. robot.turnRight()
  55. moveforward(2)
  56. robot.turnRight()
  57. moveforward(1)
  58. robot.turnLeft()
  59. end
  60. end
  61.  
  62. function moveforward(n)
  63. for i=1,n do
  64. robot.suck()
  65. robot.turnRight()
  66. robot.suck()
  67. robot.turnLeft()
  68. robot.forward()
  69. end
  70. end
  71.  
  72. function iloop()
  73. while true do
  74.  
  75. robot.turnLeft()
  76. moveforward(3)
  77. robot.turnRight()
  78. moveforward(2)
  79. treelogic()
  80. moveforward(3)
  81. treelogic()
  82. moveforward(3)
  83. treelogic()
  84. robot.turnLeft()
  85. moveforward(5)
  86. robot.turnLeft()
  87. treelogic()
  88. moveforward(3)
  89. treelogic()
  90. moveforward(3)
  91. treelogic()
  92. robot.turnRight()
  93. moveforward(5)
  94. robot.turnRight()
  95. treelogic()
  96. moveforward(3)
  97. treelogic()
  98. moveforward(3)
  99. treelogic()
  100. moveforward(2)
  101. robot.turnRight()
  102. moveforward(13)
  103. robot.turnRight()
  104. moveforward(15)
  105.  
  106. robot.turnLeft()
  107. robot.select(2)
  108. robot.drop(6)
  109. robot.turnRight()
  110. robot.forward()
  111. robot.turnLeft()
  112.  
  113. --[[
  114.  
  115. robot.select(2)
  116. int = robot.count(2) - 1
  117. component.generator.insert(int)
  118.  
  119. print("Generator Fuel: " .. component.generator.count())
  120.  
  121. --]]
  122.  
  123. total = 0
  124. total2 = 0
  125.  
  126. for i=2,16 do
  127. robot.select(i)
  128. items = robot.count(i)
  129. itemstodrop = items - 1
  130. robot.drop(itemstodrop)
  131. end
  132.  
  133. print("Compelete")
  134.  
  135. robot.turnRight()
  136. robot.select(1)
  137. print("-----------------------------------------")
  138.  
  139. robot.use(front)
  140. os.sleep(1*6)
  141. robot.use(front)
  142. robot.turnAround()
  143.  
  144. os.sleep(20*60)
  145. end
  146. end
  147.  
  148. iloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement