Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- assert(loadfile("functions"))()
- assert(loadfile("movement"))()
- branches = {}
- startingPosition = getYPos()
- twigs = {}
- returnPath = {}
- function checkWalls(checkingBranch)
- for i=1,4 do
- local success, data = turtle.inspect()
- if success then
- if string.match(data.name,"_log") or string.match(data.name,"_leaves") then
- if checkingBranch then
- table.insert(branches,1,getPos())-- add block position to memory
- else
- table.insert(twigs,1,getPos())-- add block position to memory
- end
- --else
- --turtle.dig()-- not a log. KILL IT
- end
- end
- move("rt")
- end
- end
- function goToBranch(branch)
- moveY(split(branch)[2])
- moveF(split(branch)[4])
- end
- function killTwigs()
- if #twigs == 0 then return end-- return if no twiggers
- --turn to twig
- turns = moveF(split(twigs[1])[4])
- if type(turns) == "table" then
- for k,v in pairs(turns) do
- table.insert(returnPath,1,v)
- end
- end
- --dig twig
- turtle.dig()
- --rmv twig from twigs
- table.remove(twigs,1)
- --move fd
- move("fd")
- --add movement to returnpath
- table.insert(returnPath,1,"fd")
- --checkwalls
- checkWalls(false)
- --if twigs then RECURSE
- if #twigs>0 then
- killTwigs()
- end
- end
- function stripBranches(branches)
- for k,v in pairs(branches) do
- goToBranch(v)
- turtle.dig()
- move("fd")
- table.insert(returnPath,1,"fd")
- checkWalls(false)
- end
- end
- function Main()
- -- move to trunk location
- turtle.dig()
- move("fd")
- checkWalls()
- while turtle.inspectUp() do -- core tree and store branch locations
- turtle.digUp()
- move("up")
- checkWalls(true)
- end
- goToBranch(branches[1])
- table.insert(twigs,branches[1])
- table.remove(branches,1)
- killTwigs()
- returnPath = reverseList(returnPath)
- moveT(inversePath(returnPath))
- for k,v in pairs(returnPath) do
- print(k,v)
- end
- end
- Main()
- --branches = reverseList(branches) -- reverse branch-list so we start on top
- -- move to branch
- -- for k,v in pairs(branches) do
- -- print(v)
- --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement