Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Harvest Rows of Cane
- -- 170218 Upgraded to three sets
- RowLength=10
- NumSetsCrop=3
- NumMinHarvest=10
- -- Function to Connect to Monitor
- local mon
- local function findMonitor()
- mon=peripheral.wrap("right")
- -- mon.write("Test 1")
- if peripheral.wrap("right") then
- mon.setTextScale(3)
- mon.write("Initialized")
- return true
- else
- return false
- end
- end -- Function find monitor
- function GetIntoPos()
- turtle.up()
- turtle.up()
- end -- function GetIntoPos()
- function HarvestRow()
- for x=1,10,1 do
- turtle.dig()
- turtle.forward()
- end -- RowLength loop
- end -- function HarvestRow
- function TurnBackLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end -- function TurnBackLeft
- function TurnBackRight()
- turtle.turnRight()
- turtle.forward()
- turtle.dig()
- turtle.turnRight()
- end -- function TurnBackRigth
- ----------------------------------
- -- Return to home position and lower after pass over all crops
- function ReturnHome()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- if NumSetsCrop>1 then
- for x=1,NumSetsCrop-1,1 do
- turtle.forward()
- turtle.forward()
- turtle.forward()
- end -- of Number of Sets of Crops
- end -- if more than one row of crops
- turtle.turnLeft()
- turtle.down()
- end -- function ReturnHome
- -------------------------------
- -- Unload turtle into storage
- function UnLoad()
- turtle.turnLeft()
- for x=1,16,1 do
- turtle.drop(x)
- end
- turtle.turnRight()
- end -- function UnLoad
- --------------------------
- -- Harvest a full lap
- function HarvestLap()
- HarvestRow()
- TurnBackLeft()
- HarvestRow()
- TurnBackRight()
- HarvestRow()
- TurnBackLeft()
- HarvestRow()
- TurnBackRight()
- HarvestRow()
- TurnBackLeft()
- HarvestRow()
- end -- of function HarvestLap
- function HarvestCrop()
- print("Running Harvest Routine")
- print("Fuel Level: ", turtle.getFuelLevel())
- GetIntoPos()
- HarvestLap()
- ReturnHome()
- HarvestLap()
- ReturnHome()
- UnLoad()
- end -- HarvestCrop
- -------------------------
- -- Main Routine
- -------------------------
- MonExists=findMonitor()
- print("Name: ", os.getComputerLabel() )
- while (turtle.getFuelLevel()>100) do
- HarvestCrop()
- print("Waiting for Growth")
- print("FuelLevel: ", turtle.getFuelLevel())
- for x=NumMinHarvest,1,-1 do
- print("Minutes till Harvest: ", x)
- sleep(60)
- end -- Number of minutes to wait between harvests
- end -- While fuel remaining
- if turtle.getFuelLevel()<100 then
- print("Out of Fuel: ", turtle.getFuelLevel())
- end
Advertisement
Add Comment
Please, Sign In to add comment