Advertisement
pyrater

OC Treefarm

Apr 16th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 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. robot.turnLeft()
  12. moveforward(1)
  13. robot.turnLeft()
  14. moveforward(1)
  15. robot.turnLeft()
  16. moveforward(2)
  17. robot.turnLeft()
  18. moveforward(2)
  19. robot.turnLeft()
  20. moveforward(1)
  21. robot.turnLeft()
  22. robot.suck()
  23. robot.place()
  24. robot.turnAround()
  25. else
  26. robot.suck()
  27. robot.turnLeft()
  28. robot.forward()
  29. robot.turnRight()
  30. moveforward(2)
  31. robot.turnRight()
  32. moveforward(1)
  33. robot.turnLeft()
  34. end
  35. end
  36.  
  37. function moveforward(n)
  38. for i=1,n do
  39. robot.suck()
  40. robot.turnRight()
  41. robot.suck()
  42. robot.turnLeft()
  43. robot.forward()
  44. end
  45. end
  46.  
  47. function iloop()
  48. while true do
  49.  
  50. robot.turnLeft()
  51. moveforward(3)
  52. robot.turnRight()
  53. moveforward(2)
  54. treelogic()
  55. moveforward(3)
  56. treelogic()
  57. moveforward(3)
  58. treelogic()
  59. robot.turnLeft()
  60. moveforward(5)
  61. robot.turnLeft()
  62. treelogic()
  63. moveforward(3)
  64. treelogic()
  65. moveforward(3)
  66. treelogic()
  67. robot.turnRight()
  68. moveforward(5)
  69. robot.turnRight()
  70. treelogic()
  71. moveforward(3)
  72. treelogic()
  73. moveforward(3)
  74. treelogic()
  75. moveforward(2)
  76. robot.turnRight()
  77. moveforward(13)
  78. robot.turnRight()
  79. moveforward(16)
  80. robot.turnLeft()
  81.  
  82. robot.select(2)
  83. int = robot.count(2) - 1
  84. component.generator.insert(int)
  85.  
  86. print("Generator Fuel: " .. component.generator.count())
  87.  
  88. total = 0
  89. total2 = 0
  90. for i=2,16 do
  91. robot.select(i)
  92. items = robot.count(i)
  93. itemstodrop = items - 1
  94. robot.drop(itemstodrop)
  95. total = total2 + itemstodrop
  96. end
  97.  
  98. print(total2 .. " logs collected after fueling")
  99.  
  100.  
  101. robot.turnLeft()
  102. robot.select(1)
  103. print("-----------------------------------------")
  104. os.sleep(5*60)
  105. end
  106. end
  107.  
  108. iloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement