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

My First Program: An Awesome Branch Miner!

Started by TheThirdPerson, 07 August 2013 - 10:29 AM
TheThirdPerson #1
Posted 07 August 2013 - 12:29 PM
Hello computercraft forums! I have very recently gotten into programming and turtles have turned out to be the most fun way to learn I've ever found. After two (very) late nights I have finally written a working and well-featured branch mining program.

I'm sure that this forum is positively inundated with posts almost exactly like this one, but I would really appreciate some folks looking over this and offering suggestions. I did as much as I could without looking at other programs to see how they did it, and instead tried to figure it out just looking at the turtle API and the LUA manual.

The program will cause the turtle to dig a central shaft with the number of brances, length of branches, and distance between them specified by the user. It places torches before and at the end of each branch and will return home when its inventory is full to dump it all into a chest (placed behind the turtle at startup). It calculates the fuel cost at the beginning and ensures that it has enough to complete the whole job (this seems more efficient to me than refueling on the go or using fuel to come get more fuel… also it was easier).

Anyway, to the pastebin!

http://pastebin.com/sRzC6NEf

Any thoughts or critiques would be greatly appreciated.
AFN360 #2
Posted 09 August 2013 - 05:09 PM
Great program! But I have a problem. So the first time I used it it worked perfectly but now the second/third time I have used it when it tries to return to the chest it is off by a few blocks and sometimes gets stuck and won't mine anymore till I free it but ti still spews all the contents all over the floor which makes it hard to organize haha. So do you know what's wrong?
TheThirdPerson #3
Posted 12 August 2013 - 05:59 PM
Yeah I am having a little trouble with how it deals with gravel. I have found in using it that whenever the turtle disappears for an oddly long time it's because he's stuck. This may or may not also mess with the counter used to get home, which might be why it's not making it.

New versions are uploaded all the time as I screw with it. Thanks a lot for checking it out!
H4X0RZ #4
Posted 12 August 2013 - 06:29 PM
I can't believe that THIS is your first program :D/>
topcat13 #5
Posted 12 August 2013 - 08:49 PM
Not getting any errors but it only tells me what the fuel requirement is and then doesn't do anything.
Nevermind it's working. I'm just a moron.
Thanks for the code!
Darkey #6
Posted 13 November 2013 - 12:37 PM
any chance you can make it so it doesnt get stuck my gravel ??