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

branch mining program

Started by jeppebra, 27 March 2013 - 03:22 AM
jeppebra #1
Posted 27 March 2013 - 04:22 AM
Hi, i wrote a pretty simple program that mines a 1x3 trench forever. In the turtles first slot you will need to put in the a enderchest you use for sorting. In the second slot you will need to put in a enderchest for coal. in the third slot you will need to put in a enderchest for torches, and a torch in the fourth slot. The two last steps are optional and very easy to turn off, i made it easy to turn off because it's difficult to automatically fill a chest with torches.

Here is a link to the code:
http://pastebin.com/apgqpSbb

Please tell me what you think!
I just started playing around with computer craft and this is actually my second program ever!
i hope you like it and it is useful.

Jeppebra

(ps. when theres a backlog in your sorting system the turtle is not going to drop anything, but it will stand around for a little while. I didn't fix this because it wasn't a real problem for me, it will catch up eventually and continue where it left off.
civilwargeeky #2
Posted 29 March 2013 - 04:52 PM
Nice program. Its good to get started off with things like this. Just a couple of general tips: In your refuel function, you print the fuel level from the beginning, not after you refueled it (not sure if intended). Also, when you move the turtle, a really simple way to move is
 while not turtle.forward() do
turtle.dig()
sleep(0.1) --optional
end
This will deal with any block that falls in front of it (or players ;)/> )
PonyKuu #3
Posted 29 March 2013 - 05:17 PM
to deal with players, it's better to do this:

while not turtle.forward() do
  if turtle.detect() then
    turtle.dig()
  else
    turtle.attack() 		  
  end
end
^_~
jeppebra #4
Posted 30 March 2013 - 06:04 AM
Thank you so much for the heads up on the gravel thing, belive it or not i really tried to come up with a good way of doing it… I only see one problem with it and that is with the torches. If i use the simple code its going to count every piece of gravel as "i" and therefor there might be inconsistencies in the torchplacement. Is there a better way of doing the torches? And i'm not that concerned with players because it's just going to go straight and i don't think people will get in its way, and monsters won't spawn when i'm not around :)/>