Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- queryleft = false
- h = 1
- p = 3
- function supplyCheck()
- print("checking for supplies")
- if turtle.getItemCount(1) < 10
- or turtle.getItemCount(3) < 20
- or turtle.getItemCount(8) > 32
- then
- needsSupply = true
- else needsSupply = false
- end
- if needsSupply then backtoBase()
- end
- end
- function fuelCheck()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel < 100 then
- turtle.select(1)
- repeat
- turtle.refuel(1)
- local fuelLevel = turtle.getFuelLevel()
- until fuelLevel > 750
- print("Refueled!")
- end
- end
- function checks()
- fuelCheck()
- if p == 3 then
- supplyCheck()
- end
- end
- function homeBase()
- local success, data = turtle.inspectDown()
- if data.name == "minecraft:chest" then
- if needsSupply then supplyGet()
- end
- if turtle.getItemCount(8) > 32 then logDeposit()
- end
- backtoWork()
- end
- end
- function supplyGet()
- if turtle.getItemCount(1) < 10 then
- turtle.select(1)
- repeat turtle.suckDown(1)
- until turtle.getItemCount(1) > 40
- print("Charcoal restocked")
- end
- if turtle.getItemCount(3) < 20 then
- turtle.select(3)
- repeat turtle.suckUp(1)
- until turtle.getItemCount(3) > 30
- print("Saplings restocked")
- turtle.select(1)
- end
- end
- function logDeposit()
- turtle.turnLeft()
- turtle.select(2)
- turtle.drop(60)
- for wslot = 4,16 do
- turtle.select(wslot)
- turtle.drop(64)
- end
- print("Logs deposited")
- turtle.select(1)
- turtle.turnRight()
- end
- function backtoBase()
- local success, data = turtle.inspectDown()
- if data.name ~= "minecraft:chest" then
- repeat
- turtle.back()
- local success, data = turtle.inspectDown()
- until data.name == "minecraft:chest"
- print("Back at base")
- homeBase()
- end
- end
- function backtoWork()
- print("Back to work!")
- l = 0
- repeat
- if turtle.detect() then leafClear()
- else turtle.forward()
- end
- l = l + 1
- until l == 4
- l = 0
- if queryleft == true then searchRight()
- else searchLeft()
- end
- end
- function chopTree()
- turtle.dig()
- turtle.forward()
- while turtle.detectUp() == true do
- turtle.dig()
- turtle.digUp()
- turtle.up()
- h = h + 1
- end
- print("This tree was " .. h .. "m tall")
- turtle.dig()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turtle.dig()
- while turtle.detectDown() == true and h ~= 1 do
- turtle.digDown()
- turtle.down()
- h = h - 1
- turtle.dig()
- end
- turtle.select(3)
- turtle.place()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.place()
- turtle.turnLeft()
- turtle.back()
- turtle.place()
- end
- function searchRight()
- local success, data = turtle.inspect()
- if data.name ~= "minecraft:log" then
- turtle.turnRight()
- l = 0
- repeat
- if turtle.detect() then
- leafClear()
- else turtle.forward()
- end
- l = l + 1
- until l == 6
- l = 0
- turtle.turnLeft()
- p = p + 1
- turtle.select(4)
- turtle.place()
- turtle.select(1)
- checks()
- else chopTree() checks()
- end
- if p == 4 then
- searchLeft()
- queryleft = false
- else searchRight()
- end
- end
- function searchLeft()
- local success, data = turtle.inspect()
- if data.name ~= "minecraft:log" then
- turtle.turnLeft()
- l = 0
- repeat
- if turtle.detect() then
- leafClear()
- else turtle.forward()
- end
- l = l + 1
- until l == 6
- l = 0
- turtle.turnRight()
- p = p - 1
- turtle.select(4)
- turtle.place()
- turtle.select(1)
- checks()
- else chopTree() checks()
- end
- if p == 1 then
- searchRight()
- queryleft = true
- else searchLeft()
- end
- end
- function leafClear()
- local success, data = turtle.inspect()
- if data.name == "minecraft:leaves" and h == 1 then
- print("leaf")
- turtle.dig()
- turtle.forward()
- end
- end
- while true do
- homeBase()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement