Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Program that harvests Redwood trees with a specific chest setup.
- local tArgs = { ... }
- if # tArgs ~= 1 then
- print("Usage: autoHarvest <iterations>")
- return
- end
- local count = tonumber(tArgs[1])
- local function harvest()
- turtle.select(3)
- turtle.dig()
- turtle.forward()
- while turtle.detectUp() do
- turtle.dig()
- turtle.digUp()
- turtle.up()
- end
- turtle.dig()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- while turtle.detectDown() do
- turtle.dig()
- turtle.digDown()
- turtle.down()
- end
- turtle.up()
- turtle.select(16)
- turtle.placeDown()
- end
- local function invDump()
- for i = 1,13 do
- turtle.select(i+2)
- turtle.drop()
- end
- end
- local function restock()
- if turtle.getItemCount(1) < 4 then --Saplings in slot 1
- turtle.select(1)
- turtle.dropUp()
- turtle.suckUp()
- end
- if turtle.getItemCount(2) < 10 then --Bone meal in slot 2
- turtle.select(2)
- turtle.dropDown()
- turtle.suckDown()
- end
- turtle.turnRight()
- if turtle.getFuelLevel() < 500 then
- turtle.select(15)
- turtle.suck()
- turtle.refuel()
- end
- turtle.turnRight()
- end
- local function forward(dist)
- for i = 1,dist do
- turtle.forward()
- end
- end
- local function replant()
- turtle.select(1)
- turtle.placeDown()
- forward(1)
- turtle.placeDown()
- turtle.turnRight()
- forward(1)
- turtle.placeDown()
- turtle.turnRight()
- forward(1)
- turtle.placeDown()
- forward(1)
- turtle.turnRight()
- forward(1)
- turtle.down()
- turtle.turnRight()
- turtle.select(2)
- while turtle.place() do
- sleep(0.5)
- end
- end
- --Main Loop
- while true do
- print("Make sure to keep at least 2 dirt in slot 16. Press E to continue.")
- local event, param1 = os.pullEvent("char")
- if param1 == "e" then
- term.clear()
- print("Harvesting " .. count .. "trees.")
- break
- else
- sleep(0.5)
- end
- end
- for i = 1,count do
- restock()
- forward(5)
- replant()
- harvest()
- turtle.turnLeft()
- forward(1)
- turtle.turnLeft()
- turtle.up()
- forward(5)
- invDump()
- sleep(300)
- end
- print("Finished harvesting " .. count .. " trees!")
Advertisement
Add Comment
Please, Sign In to add comment