Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Robot modules,functions,variables
- ---------------------------------------------------------------
- local component = require("component")
- local robot = require("robot")
- local sides = require("sides")
- local geolyzer = component.proxy(component.get("935"))
- local x = 7 --deep
- local y = 10 --wide
- local facing = "forward"
- local temp = "place holder"
- function harvestRows(s)
- for i=1,s-1 do --deep loop
- -- robot.placeDown() --plants crop below robot
- -- robot.forward(1)
- local scan = geolyzer.analyze(sides.down) --scans metadata of block below to see if it's ready for harvest
- for k,v in pairs(scan) do
- if scan.metadata == 3 then
- robot.swingDown() --harvests plant
- end
- end
- robot.placeDown()
- robot.forward()
- end
- end
- function nextRow(s)
- if s == "forward" then
- robot.turnRight()
- harvestRows(2)
- -- robot.forward(1)
- -- harvestRows(1)
- robot.turnRight()
- temp = "back"
- end
- if s == "back" then
- robot.turnLeft()
- harvestRows(2)
- robot.turnLeft()
- temp = "forward"
- end
- facing = temp
- end
- function toStart(s)
- if s == "forward" then
- robot.turnLeft()
- for i=1,y do robot.forward(1) end
- robot.turnRight()
- end
- if s == "back" then
- for i=1,x-1 do robot.forward(1) end
- robot.turnRight()
- for i=1,y do robot.forward(1) end
- robot.turnRight()
- end
- end
- ------------------------------------------------------------------------------------------
- --Robot program
- -----------------------------------------------------------------------------------------
- for i=1,y do --for the width of the farm
- harvestRows(x) --harvest a row x deep
- nextRow(facing) --move to the next row and turn around
- end
- toStart(facing) --return robot to start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement