Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Thanks for using Lumberjack v3, feel free to copy, distribute or edit this program. - Melodicolt")
- direction = 0
- function mainLoop()
- refuelTurtle()
- checkInventory()
- if turtle.detect() then
- process()
- end
- turtle.forward()
- end
- function refuelTurtle()
- if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 50 then
- local fuelCounter = 0
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- local data = turtle.getItemDetail(i)
- if data.name == "minecraft:coal" then
- turtle.select(i)
- turtle.refuel()
- else
- fuelCounter = fuelCounter + 1
- end
- end
- end
- if fuelCounter == 16 then
- print("I'm out of fuel.")
- fuelCounter = 0
- end
- end
- end
- function checkInventory()
- local emptyInvSlots = 0
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- emptyInvSlots = emptyInvSlots + 1
- end
- end
- if emptyInvSlots == 0 then
- print("Inventory full.")
- else
- emptyInvSlots = 0
- end
- end
- function process()
- local success, data = turtle.inspect()
- if data.name == "minecraft:log" then
- local movesUp = 0
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- while turtle.detectUp() do
- local success, data = turtle.inspectUp()
- if data.name == "minecraft:log" then
- turtle.digUp()
- turtle.up()
- movesUp = movesUp + 1
- else
- turtle.digUp()
- end
- end
- while movesUp ~= 0 do
- turtle.down()
- movesUp = movesUp - 1
- end
- local saplings = 0
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- local data = turtle.getItemDetail(i)
- if data.name == "minecraft:sapling" then
- turtle.select(i)
- turtle.placeDown()
- saplings = saplings + 1
- end
- end
- end
- if saplings == 0 then
- print("Out of saplings.")
- end
- elseif data.name == "minecraft:fence" then
- local success, data = turtle.inspectDown()
- if data.name == "IronChest:BlockIronChest" then
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- local data = turtle.getItemDetail(i)
- if data.name == "minecraft:log" then
- turtle.select(i)
- turtle.dropDown()
- end
- end
- end
- end
- if direction == 0 then
- turtle.turnRight()
- local success, data = turtle.inspect()
- if data.name == "minecraft:leaves" then
- turtle.dig()
- end
- if turtle.forward() then
- turtle.turnRight()
- direction = 1
- else
- turtle.turnLeft()
- turtle.turnLeft()
- if turtle.forward() then
- turtle.turnLeft()
- end
- end
- elseif direction == 1 then
- turtle.turnLeft()
- local success, data = turtle.inspect()
- if data.name == "minecraft:leaves" then
- turtle.dig()
- end
- if turtle.forward() then
- turtle.turnLeft()
- direction = 0
- else
- turtle.turnRight()
- turtle.turnRight()
- if turtle.forward() then
- turtle.turnRight()
- end
- end
- else
- print("Direction is messed up.")
- end
- else
- turtle.dig()
- end
- end
- while true do
- mainLoop()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement