Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --"Lumberjack Turtle" v2.4-dev
- -- Author: Daniele "Raniel" Sabre
- -- configuration
- woodToUseForFuel = 1 -- higher number = less wood produced but more sustain (set 0 to deactivate)
- minFuelRequired = 20
- wait = 5
- slotWood = 1
- slotsBoneMeal = {5, 6, 7, 8}
- slotsSaplings = {9, 10, 11, 12}
- slotCompare = 16
- print("Lumberjack started")
- print("[hold ctrl+t to terminate]")
- turtle.select(slotCompare)
- counterLoop = 0
- continue = true
- while turtle.getFuelLevel() > minFuelRequired and continue do -- if the fuel gets below the loop stops
- -- increment counter
- counterLoop = counterLoop + 1
- -- compare the sapling with the block in front of the turtle
- while turtle.compare() do
- -- bone meal action
- for k, v in pairs(slotsBoneMeal) do
- data = turtle.getItemDetail(v)
- if data then
- if data.name == "minecraft:dye" then
- turtle.select(v)
- turtle.place()
- turtle.select(slotCompare)
- break
- end
- end
- end
- sleep(wait)
- end
- -- init procedure to get wood from tree
- turtle.select(slotWood)
- turtle.dig()
- turtle.forward()
- -- the turtle will keep going up until there are no more blocks above him
- while turtle.detectUp() == true do
- turtle.digUp()
- turtle.up()
- end
- -- go down
- while turtle.down() == true do
- end
- -- until it hits the ground
- turtle.back()
- -- place a new sapling
- found = false
- for k, v in pairs(slotsSaplings) do
- data = turtle.getItemDetail(v)
- if data.name == "minecraft:sapling" then
- turtle.select(v)
- turtle.place()
- found = true -- sapling found
- break
- end
- end
- -- if no sapling are found this is the last cycle
- if not found then
- continue = false
- end
- -- select the slot of the wood
- turtle.select(1)
- -- use of wood to refuel turtle
- if woodToUseForFuel > 0 then
- turtle.refuel(woodToUseForFuel)
- end
- turtle.dropDown() -- dropDown the remain woods
- -- reselect slot compare
- turtle.select(slotCompare)
- print("Cycle "..counterLoop.." completed")
- end
- -- if the turtle runs out of fuel, it will print a message and terminate the program
- print("Empty fuel or saplings not found")
Add Comment
Please, Sign In to add comment