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

Multiple Programs Running On A Turtle?

Started by QuestinHowl, 12 September 2014 - 02:34 AM
QuestinHowl #1
Posted 12 September 2014 - 04:34 AM
Hi,
I'm new to ComputerCraft but I still know a few basic commands.

I'm trying to set up a system where a mining turtle does:

> tunnel 3
> excavate 2

This is a simple example of a way to collect a ton of resources down to bedrock in a line with a simple walkway down the side

I need a way to do this automatically without having to type the commands separately. I'd also like a way to repeat the process infinitely, and also a system that tells the turtle to collect coal from a chest when it needs it, refuel itself, and go back to where it was. Also maybe a system to drop off and/or separate the materials it collects into a set of chests when it runs out of inventory space.

I'd also like a way to have the turtle plant a sapling on a certain block, bone meal it until it is grown, chop down the tree, collect the saplings and wood, then put them in a chest. I would love if this could be set up for multiple trees at once, but just one tree would be fine. Also again a system to collect coal and refuel itself when it needs to, and as well to grab saplings/bone meal from the chest when it runs out.

If anyone has any idea how to do this please let me know. It would be much appreciated.
KingofGamesYami #2
Posted 12 September 2014 - 01:38 PM
You'd be better off recoding both programs into your turtle. For this, you will need a good understanding of the turtle api. You will also need to understand while loopsand for loops.

Some random help bits:

--#turtle will get rid of stuff in its path and move forward once
while not turtle.forward() do
  turtle.dig()
  turtle.attack()
end


--#growing a tree
turtle.select( i ) --#replace i with the slot you have logs in
while not turtle.compare() do
  turtle.select( v ) --#replace v with bonemeal slot
  turtle.place() --#should use bonemeal, if a turtle can even do this
  turtle.select( i )
end


--#digging a tree, assuming you are on the same level as the sapling
turtle.dig()
turtle.forward()
while turtle.digUp() do
  turtle.up()
  for i = 1, 4 do
    turtle.turnRight()
    turtle.dig()
  end
end
--#return to previous position
while turtle.down() do end
turtle.back()
QuestinHowl #3
Posted 12 September 2014 - 08:42 PM
Thanks a ton!

I will make sure to check out the links you sent me.

I still have one question, though.

Is there a way to have the turtle separate the materials it collects into multiple different chests based on the material it is?

Never mind, I'll look into coding it myself.
Edited on 13 September 2014 - 01:35 AM
Bomb Bloke #4
Posted 13 September 2014 - 02:52 AM
There are a number of ways, but the one I've found to be easiest thus far is to get it to dump everything into one chest, then pump stuff from there into eg diamond pipes and so on.

This allows me to put drop off chests all around my base, into any of which I can place unneeded items myself. Trash gets deleted, everything else goes into storage somewhere.
QuestinHowl #5
Posted 19 September 2014 - 04:57 PM
That is probably the easiest solution and I did set up a system for this in a singleplayer world. The only problem would be if I'm not playing in a modpack like ftb or tekkit, where there is not both of these mods. Honestly though, if i'm going to be playing with one of these mods, I'll probably be using the other too.
Thanks!