This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
siaro's profile picture

Best way to excavate this tree?

Started by siaro, 28 March 2015 - 06:42 PM
siaro #1
Posted 28 March 2015 - 07:42 PM
Hey guys im new to this forum I just got a quick question for you guys.
Do you guys know a script that can excavate a tree like this going upwards essentially, leaving out the outside so you can build and live inside of it etc:
Spoiler

This is the inside, it has 2 types of logs. They grey one is the outside log and the red/brown one the inside log.
. Thanks in advance!
Lyqyd #2
Posted 28 March 2015 - 08:17 PM
Moved to Ask a Pro.
Lupus590 #3
Posted 28 March 2015 - 10:42 PM
test if the turtle can tell the difference between the two types of log
if yes to above, write/adapt a tree logging program to chop until the block above is not what the turtle is currently chopping
else, turtle can't do it

you will need to know how to use turtle.compare or turtle.inspect
HPWebcamAble #4
Posted 28 March 2015 - 11:59 PM
I think you'll need to use a recursive function

Most turtle mining programs use a recursive function to mine ore veins. You could try editing one to only mine the inner tree log
Lupus590 #5
Posted 29 March 2015 - 03:17 PM
that is a big tree for recursive functions, you may fill the function stack

a good way actually may be to combine our two techniques, recursive miner on the bottom level, with tree logger program to get the rest, the miner bit will find the next 'tree'
HPWebcamAble #6
Posted 29 March 2015 - 06:37 PM
that is a big tree for recursive functions, you may fill the function stack

Ehh, it will most likely, but that just means the turtle would have to be restarted a few times

Honestly, Computer Craft isn't very well suited for this. If you have a mod like buildcraft then you can use a filler to clear a majority of the inside.
Bomb Bloke #7
Posted 29 March 2015 - 11:23 PM
The turtle need not crash; it's simply a matter of making a "miner" that doesn't recurse. Use a table to keep track of your progress and nest a couple of while loops instead.
TechedZombie #8
Posted 30 March 2015 - 11:58 PM
How do recursive functions work? (Sorry If it is obvious :(/> )
HPWebcamAble #9
Posted 31 March 2015 - 12:56 AM
How do recursive functions work? (Sorry If it is obvious :(/> )

It would probably be better for you to make your own topic instead of posting on this one

Basically, its just a function that calls itself


function test()
  test()
end
This wouldn't do anything, but a good example would my Craft Compress program:

This is the function that actually compresses stuff
It might be a little bit complicated, but notice how it calls itself in order to keep going through directories

local function compressPath(path,iPath)
  path = shell.resolve(path)
  local dir = fs.list(path)
  for i = 1, #dir do
	if fs.isDir(path.."/"..dir[i]) then                          --# If the thing is a directory...
	  compressPath(path.."/"..dir[i],iPath.."/"..dir[i])			--# Recursive call
	else	  --# The thing is a file, open it and 'compress' it
	  local tempFile = {}
	  table.insert(file,iPath.."/"..dir[i])
	  local tempFile = readFile(path.."/"..dir[i])
	  table.insert(file,#tempFile)
	  for i = 1, #tempFile do
		table.insert(file,tempFile[i])
	  end
	end
  end
end
Edited on 30 March 2015 - 10:58 PM