Advertisement
Guest User

sugarcane.lua

a guest
Nov 20th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. local robot = require 'robot'
  2. local move = require 'move'
  3. local mine = require 'mine'
  4. local component = require 'component'
  5. local sides = require 'sides'
  6. local sugarcane = {}
  7. --
  8. print("Initializing...")
  9.  
  10. function sugarcane.deposit()
  11.   count = 19
  12.     repeat
  13.       component.inventory_controller.dropIntoSlot(3, count, 64)
  14.       count = count + 1
  15.     until count > 27
  16.   count = 19
  17. end
  18.  
  19. function sugarcane.rowHarvest(x)
  20.   x = 1
  21.   for i = 1, x do
  22.     move.forward(8)
  23.   end
  24. end
  25.  
  26. function sugarcane.topHarvest(x)
  27.   x = 1
  28.   for i = 1, x do
  29.     sugarcane.rowHarvest()
  30.     robot.turnAround()
  31.     move.right(2)
  32.     sugarcane.rowHarvest()
  33.     robot.turnAround()
  34.     move.left(1)
  35.     sugarcane.rowHarvest()
  36.     robot.turnAround()
  37.     move.right(2)
  38.     sugarcane.rowHarvest()
  39.     robot.turnAround()
  40.     move.left(1)
  41.     sugarcane.rowHarvest()
  42.     robot.turnAround()
  43.     move.right(2)
  44.     sugarcane.rowHarvest()
  45.   end
  46. end
  47.  
  48. function sugarcane.midHarvest(x)
  49.   x = 1
  50.   for i = 1, x do
  51.     sugarcane.rowHarvest()
  52.     robot.turnAround()
  53.     move.right(2)
  54.     sugarcane.rowHarvest()
  55.     robot.turnAround()
  56.     move.left(1)
  57.     sugarcane.rowHarvest()
  58.     robot.turnAround()
  59.     move.right(2)
  60.     sugarcane.rowHarvest()
  61.     robot.turnAround()
  62.     move.left(1)
  63.     sugarcane.rowHarvest()
  64.     robot.turnAround()
  65.     move.right(2)
  66.     sugarcane.rowHarvest()
  67.   end
  68. end
  69.  
  70. function sugarcane.Field1(x)
  71.   x = 1
  72.   while x == 1 do
  73.     print("Moving to position.")
  74.     move.up()
  75.     move.forward()
  76.     move.right(3)
  77.     move.forward()
  78.     print("In position, begin harvest.")
  79.     sugarcane.topHarvest()
  80.     robot.turnAround()
  81.     move.right(8)
  82.     move.down()
  83.     sugarcane.midHarvest()
  84.     print("Harvest complete, moving to deposit inventory and recharge")
  85.     move.up()
  86.     move.forward(2)
  87.     move.left(5)
  88.     robot.turnAround()
  89.     move.down()
  90.     print("Depositing inventory.")
  91. --    component.inventory_controller.dropIntoSlot(3, 25, 64)
  92. --    component.inventory_controller.dropIntoSlot(3, 26, 64)
  93. --    component.inventory_controller.dropIntoSlot(3, 27, 64)
  94.     sugarcane.deposit()
  95.     print("Recharging.")
  96.     os.sleep(30)
  97.     print("Charge complete")
  98.   end
  99. end
  100.  
  101. return sugarcane
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement