Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local trees = 23
- local currentPos = 0
- local lastStatus = 0
- local status = 0 -- 0Clueless-1Starting-2Harvesting-3Returning-4onRail-5OffRailDirt-6RailEnd
- -- refuel the turtle with slot 1, coal
- function Refuel()
- turtle.select(1)
- turtle.refuel(3)
- end
- --grabs fuel from coal chest
- function GrabFuel()
- turtle.turnLeft()
- turtle.select(1)
- turtle.suck()
- turtle.turnRight()
- end
- -- move forward once and suck up items front, left and right
- function Forward()
- turtle.forward()
- turtle.suckDown()
- turtle.turnLeft()
- turtle.suck()
- turtle.turnRight()
- turtle.turnRight()
- turtle.suck()
- end
- -- This function checks where the turtle is located on the rail, it's needed in case the program boots while the
- -- turtle is not at the start of the dropoff location
- function UpdateStatus()
- local s, under = turtle.inspectDown()
- local s2, front = turtle.inspect()
- lastStatus = status
- if s then
- if under.name == "minecraft:cobblestone" then
- status = 1
- end
- if under.name == "minecraft:torch" then
- status = 4
- end
- if under.name == "minecraft:dirt" then
- status = 5
- end
- end --todo: check if on right y level, should be if s is false
- if s2 then
- if front.name == "minecraft:chest" then
- turtle.turnLeft()
- turtle.turnLeft()
- status = 1
- end
- if front.name == "minecraft:log" then
- turtle.turnLeft()
- UpdateStatus()
- end
- if front.name == "minecraft:gravel" then
- status = 6
- end
- elseif status == 4 then
- turtle.forward()
- end
- print("Updated Status: " .. lastStatus .. " to " .. status)
- end
- -- main loop
- -- reset -> refuel -> pickup fuel -> chop -> deposit
- while true do
- if status == 0 then
- print("Updating status..")
- UpdateStatus()
- end
- if turtle.getItemCount(1) < 16 and status == 0 then
- print("Grabbing Fuel..")
- GrabFuel()
- end
- if turtle.getFuelLevel() < 5 then
- print("Refueling..")
- Refuel()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement