Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local component = require("component")
- side = require("sides")
- inv = component.inventory_controller
- -- 0 = nothing, 1 = shift place, 2 = swing
- function putInAnlzer()
- robot.dropUp()
- end
- function takeFromAnlzer()
- inv.suckFromSlot(1,1)
- robot.select(1)
- end
- function checkCount(slot)
- itemInfo = inv.getStackInInternalSlot(slot)
- if itemInfo ~= nil and itemInfo.size == 1 then
- return true
- end
- return false
- end
- local function forward(times,action)
- times = times or 1
- for i = 1, times do
- robot.forward()
- if action == 1 then
- robot.placeDown(0,true)
- elseif action == 2 then
- robot.swingDown()
- end
- end
- end
- local function getSeed()
- robot.turnRight()
- robot.select(2)
- robot.suck()
- robot.select(1)
- robot.turnLeft()
- end
- local function plant()
- robot.select(1)
- robot.placeDown()
- robot.select(2)
- inv.equip()
- robot.useDown()
- inv.equip()
- robot.select(1)
- forward(6,1)
- robot.turnRight()
- forward(6,1)
- robot.turnRight()
- forward(6,1)
- robot.turnRight()
- forward(2,1)
- robot.turnRight()
- forward(4,1)
- robot.turnLeft()
- forward(2,1)
- robot.turnLeft()
- forward(4,1)
- robot.turnAround()
- forward(1)
- robot.turnLeft()
- forward(2)
- robot.turnRight()
- robot.back()
- end
- local function collect()
- robot.swingDown()
- forward(6,2)
- robot.turnRight()
- forward(6,2)
- robot.turnRight()
- forward(6,2)
- robot.turnRight()
- forward(2,2)
- robot.turnRight()
- forward(4,2)
- robot.turnLeft()
- forward(2,2)
- robot.turnLeft()
- forward(3,2)
- robot.forward()
- for i=2,robot.inventorySize() do
- robot.select(i)
- robot.drop()
- end
- robot.select(1)
- robot.swingDown()
- for i=2,robot.inventorySize() do
- if checkCount(i) then
- robot.select(i)
- putInAnlzer()
- break
- end
- end
- os.sleep(6)
- takeFromAnlzer()
- robot.select(1)
- robot.turnAround()
- forward(1)
- robot.turnLeft()
- forward(2)
- robot.turnRight()
- robot.back()
- end
- local function dumpAll()
- robot.turnAround()
- for i=1,robot.inventorySize() do
- robot.select(i)
- robot.drop()
- end
- robot.turnAround()
- robot.select(1)
- end
- local function getSticks()
- robot.turnLeft()
- robot.select(1)
- robot.suck()
- robot.turnRight()
- end
- while true do
- itemInfo = inv.getStackInInternalSlot(2)
- if itemInfo ~= nil then
- plant()
- os.sleep(120)
- collect()
- dumpAll()
- getSticks()
- getSeed()
- else
- print("Waiting for Seeds")
- os.sleep(5)
- getSeed()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement