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

[Turtle] Branch Mining Program

Started by PhyscoKillerMonkey, 07 April 2012 - 09:27 AM
PhyscoKillerMonkey #1
Posted 07 April 2012 - 11:27 AM
This is just a little program I coded to help with my search for ores in my mine. It's pretty simple, just digging a 1x2 tunnel of the entered length (will get to that in a bit) and then returning to the entrance of the branch, placing torches as it goes (if that is turned on).

Usage
First dig out the main tunnel for the branches to branch off and then put the turtle down in front of the wall you want to put a branch in and start the program. There are two arguments that can be entered after the program name: the branches length and whether to place torches. So for example 'branch 64 nt' would make a tunnel 64 blocks long with no torches placed, whilst 'branch 64' or branch 64 t' would dig the same length tunnel but place torches. Simples!

Code

--Getting the variables
local tArgs = { ... }
steps = tonumber(tArgs[1])
torch = tArgs[2]

--Assigning defaults
steps = steps or 1
torch = torch or "t"


–Starting the dig
for x = 1, steps
if turtle.forward() == false then
repeat
turtle.dig()
sleep(0.25)
until turtle.forward() == true
end
end

–Getting into position for the return
turtle.digUp()
turtle.up()
turtle.turnRight()
turtle.turnRight()

–Changing the variable to allow for torches to be placed every 8
steps = steps / 8

–Starting the return
for x = 1, steps do
if torch == "t" then
turtle.turnLeft()
turtle.dig()
turtle.place()
turtle.turnRight()
end

for x = 1, 8 do
if turtle.forward() == false then
repeat
turtle.dig()
sleep(0.25)
until turtle.forward() == true
end
end
end


Todo:
Add pics and possibly a video.
Mlmiii #2
Posted 09 April 2012 - 12:38 AM
Excuse my stupidity, but how does one install this?
Cherrie #3
Posted 18 April 2012 - 08:14 PM
copy this, save in a file in minecraft dir/mods/CC/lua/rom/programs/turtle (or create more folders inside). run ingame by filename :)/>/>
harekyr #4
Posted 09 May 2012 - 07:14 PM
Hey there, i can't get this working. I followed instructions in last post but i always get this error

bios:206: [string "branchtunnel"]:12: 'do' expected

and i don't know what to do.Plese help.

PS: sorry for bad english

PPS: sorry for spamming figured it out
masterchief47 #5
Posted 09 May 2012 - 10:47 PM
harekyr, if you figured it out, could you please explain to me how to fix this? im a beginner when it comes to LUA, and i dont see how to get rid of this error.

EDIT: Nevermind, I managed to stumble upon the solution. I just started adding 'do' after every line, and eventually got it right.
PoLoMoTo #6
Posted 10 May 2012 - 12:50 AM
harekyr, if you figured it out, could you please explain to me how to fix this? im a beginner when it comes to LUA, and i dont see how to get rid of this error.

EDIT: Nevermind, I managed to stumble upon the solution. I just started adding 'do' after every line, and eventually got it right.

Line 12 based on the error
masterchief47 #7
Posted 10 May 2012 - 02:18 AM
PoLoMoTo, i used computercraft once before now, i made my own basic light system for the BTW mod, so i know how to tell what line the error's on. oddly enough, though, adding 'do' to line 11 was what fixed it.
BigSHinyToys #8
Posted 10 May 2012 - 06:14 AM
it is so sad that BTW and CC are incompatible .. so sad :)/>/>
masterchief47 #9
Posted 10 May 2012 - 06:49 PM
when did they become incompatible?
Cloudy #10
Posted 10 May 2012 - 10:55 PM
when did they become incompatible?

When ComputerCraft moved to forge, back when turtles were first introduced.

It is BTW that is incompatible with CC, not the other way round.
masterchief47 #11
Posted 11 May 2012 - 12:40 AM
i see. well, so much for readding BTW to minecraft for just the lightbulbs. then again, theres redstone lamps now, so…
libraryaddict #12
Posted 11 May 2012 - 09:28 AM
If you are interested in light bulbs.
Why not look at redpower.
That adds colored lamps
masterchief47 #13
Posted 11 May 2012 - 07:22 PM
I'll check it out, thanks.
TheCopperWarrior #14
Posted 26 May 2012 - 12:45 PM
Thanks! this is just what i needed for my MC2 Labs!

P.S. Does it repeat itself, like go back to original point and start again?
Lyqyd #15
Posted 27 May 2012 - 05:00 AM
Here's a slightly modified version that actually works!


--Getting the variables
local tArgs = { ... }
if #tArgs < 1 then
    print("Usage: branch <length> <torches>")
    return true
end
steps = tonumber(tArgs[1])
if #tArgs >= 2 and tArgs[2] == "nt" then
    torch = false
else
    torch = true
end

--Starting the dig
for x = 1, steps do
    if not turtle.forward() then
        repeat
            turtle.dig()
            sleep(0.6)
        until turtle.forward()
    end
end

--Getting into position for the return
turtle.digUp()
turtle.up()
turtle.turnRight()
turtle.turnRight()

--Starting the return
for x = 1, steps do
    if torch and x % 8 == 0 then
        turtle.placeDown()
    end
    if not turtle.forward() then
        repeat
            turtle.dig()
            sleep(0.25)    
        until turtle.forward()
    end
end
naxyr #16
Posted 30 December 2012 - 11:47 PM
I haven't yet used turtles, but I believe this is a good place to start! thank you