Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- simp_tree.lua: Enhanced tree felling with branch handling
- -- Array of valid wood block IDs (expand as needed for ATM 10 trees) for use with 1x1 girth trees
- -- credit: derivative from Grok's original work
- -- usage: place at base of tree facing 'into' trunk, it'll step forward and move up.
- local woodBlocks = {
- "minecraft:oak_log",
- "minecraft:cherry_log",
- "minecraft:spruce_log",
- "minecraft:birch_log",
- "minecraft:jungle_log",
- "minecraft:acacia_log",
- "minecraft:dark_oak_log",
- "regions_unexplored:blackwood_log",
- "regions_unexplored:redwood_log",
- "regions_unexplored:larch_log",
- "regions_unexplored:maple_log",
- "regions_unexplored:silver_birch_log",
- "biomeswevegone:aspen_log",
- "biomeswevegone:pine_log",
- "biomeswevegone:maple_log",
- "biomeswevegone:cika_log",
- "integrateddynamics:menril_log",
- "integrateddynamics:menril_log_filled"
- -- Add modded wood types here, e.g., "some_mod:some_tree_log"
- }
- -- Function to check if a block is a wood block
- local function isWoodBlock(blockName)
- for _, wood in ipairs(woodBlocks) do
- if blockName == wood then
- return true
- end
- end
- return false
- end
- -- Function to handle a single branch in the current direction
- local function handleBranch()
- local counter = 0
- local success, data = turtle.inspect()
- -- Check if the block in front is wood
- if success and isWoodBlock(data.name) then
- while true do
- -- Dig and move forward
- turtle.dig()
- if turtle.forward() then
- counter = counter + 1
- else
- break -- Can't move forward (obstruction)
- end
- -- Check the next block
- success, data = turtle.inspect()
- if not success or not isWoodBlock(data.name) then
- break -- Hit non-wood block (leaves, air, etc.)
- end
- end
- -- Turn around (180 degrees)
- turtle.turnRight()
- turtle.turnRight()
- -- Move back to starting position
- for i = 1, counter do
- turtle.forward()
- end
- end
- end
- -- Main tree felling function
- local function fellTree()
- turtle.dig()
- turtle.forward()
- while not turtle.up() do
- -- Try to dig and move up
- turtle.digUp()
- -- Check for branches in all four directions
- for i = 1, 4 do
- handleBranch()
- turtle.turnRight() -- Check next direction
- end
- turtle.up() -- move up into block we just mined to finish this level.
- end
- while turtle.down() do
- -- do nothing just go down.
- end
- end
- -- Main program
- print("Starting simp_tree with branch handling...")
- fellTree()
- print("Tree felling complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement