Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Version:4/15/2024 21:51
- os.loadAPI("grey_api/move.lua")
- os.loadAPI("grey_api/util.lua")
- local seconds_to_wait = 60*18
- local wait_first = false
- local minimum_fuel_level = 100
- local log = "minecraft:oak_log"
- local leaves = "minecraft:oak_leaves"
- local sapling = "minecraft:oak_sapling"
- local fuel = "minecraft:charcoal"
- local breakable_blocks = {[log]=true,[leaves]=true}
- local fuels = {fuel,"minecraft:stick",log}
- local log_drop_off_height = 4
- local log_drop_off_direction = 2
- local fuel_pick_up_height = 0
- local fuel_pick_up_direction = 2
- local misc_drop_off_height = 4
- local misc_drop_off_direction = 1
- function chop()
- local chopping = true
- local b,block = nil
- while true do
- chopping = true
- b,block = nil
- while chopping do
- --find tree
- while turtle.getFuelLevel()<=minimum_fuel_level and util.fuel(1,fuels) do end
- if turtle.getFuelLevel()<=0 then
- print("out of fuel")
- elseif turtle.getFuelLevel()<=minimum_fuel_level then
- print("low on fuel")
- end
- b,block = turtle.inspect()
- while not b do
- if move.get_y() > 0 then
- move.go("down")
- end
- move.go()
- b,block = turtle.inspect()
- end
- if b and (breakable_blocks[block["name"]] or block["name"]==sapling)then
- --print("found block")
- chopping = chop_oak()
- else
- chopping = false
- end
- end--end while chopping
- move.face(2)
- print("replanting saplings")
- b,block = turtle.inspect()
- while not b or breakable_blocks[block["name"]] or block["name"]==sapling do
- --if in place for sapling
- if move.get_x() % 3 == 1 and util.select_item(sapling) then
- move.face(0)
- turtle.place()
- move.face(2)
- end
- if b then
- turtle.dig()
- end
- move.go()
- b,block = turtle.inspect()
- end
- --drop off logs
- print("dropping off logs")
- move.goto(0,log_drop_off_height,0,log_drop_off_direction)
- for i=1,16 do
- if turtle.getItemCount(i)>0 and turtle.getItemDetail(i)["name"]==log then
- turtle.select(i)
- turtle.drop()
- end
- end
- --drop off misc
- print("dropping off misc")
- move.goto(0,misc_drop_off_height,0,misc_drop_off_direction)
- for i=1,16 do
- if turtle.getItemCount(i)>0 and turtle.getItemDetail(i)["name"]~=fuel then
- turtle.select(i)
- turtle.drop()
- end
- end
- --pick up fuel
- print("picking up fuel")
- local fuel_needed = 64
- if util.select_item(fuel) then
- fuel_needed = turtle.getItemSpace(turtle.getSelectedSlot())
- end
- if fuel_needed > 0 then
- move.goto(0,fuel_pick_up_height,0,fuel_pick_up_direction)
- turtle.suck(fuel_needed)
- end
- move.return_to_home()
- --refuel
- while turtle.getFuelLevel()<=minimum_fuel_level and util.fuel(1,fuels) do end
- --wait for trees to grow
- util.wait(seconds_to_wait)
- end--end while true
- end
- function chop_oak()
- local b,block = turtle.inspect()
- --check if sapling
- if b and block["name"]=="minecraft:oak_sapling" then
- --go over sapling
- move.go("up")
- move.go("forward",2)
- move.go("down")
- print(" found sapling")
- return true
- end
- local bx=move.get_x()
- local by=move.get_y()
- local bz=move.get_z()
- local bf=move.get_facing()
- print("breaking logs")
- rtn = break_all()
- move.goto(bx,by,bz,bf)
- return rtn
- end
- function break_all()
- --refuel if needed
- while turtle.getFuelLevel() <= minimum_fuel_level and util.fuel(1,fuels) do end
- if turtle.getFuelLevel()<=0 then
- print("Out of fuel")
- elseif turtle.getFuelLevel()<=minimum_fuel_level then
- print("Low on fuel")
- end
- local b,block = turtle.inspectDown()
- --break down
- if b and breakable_blocks[block["name"]] then
- turtle.digDown()
- move.go("down")
- break_all()
- move.go("up")
- end
- --break backwards
- move.face(2)
- b,block = turtle.inspect()
- if b and breakable_blocks[block["name"]] then
- turtle.dig()
- move.go()
- break_all()
- move.face(0)
- move.go()
- end
- --break left
- move.face(3)
- b,block = turtle.inspect()
- if b and breakable_blocks[block["name"]] then
- turtle.dig()
- move.go()
- break_all()
- move.face(1)
- move.go()
- end
- --break right
- move.face(1)
- b,block = turtle.inspect()
- if b and breakable_blocks[block["name"]] then
- turtle.dig()
- move.go()
- break_all()
- move.face(3)
- move.go()
- end
- --break forward
- move.face(0)
- b,block = turtle.inspect()
- if b and breakable_blocks[block["name"]] then
- turtle.dig()
- move.go()
- break_all()
- move.face(2)
- move.go()
- end
- --break up
- b,block = turtle.inspectUp()
- if b and breakable_blocks[block["name"]] then
- turtle.digUp()
- move.go("up")
- break_all()
- move.go("down")
- end
- return true
- end
- if wait_first then util.wait(seconds_to_wait) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement