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

Tunnel mining and Branches mining

Started by HTxL, 22 March 2012 - 04:31 PM
HTxL #1
Posted 22 March 2012 - 05:31 PM
This program has 2 main Features

The first Feature is to do a tunnel of 3x2
-You can choose how deep it will go
-You can enable the "dropOff" option (what it does? :
SpoilerWhen the turtle finishes the tunnel , he will come back to the block he was standing at the begining and he will drop all of hes items



( you can use redpower buildcraft , with the "dropOff" function and store it automaticly )

The second Feature is mining branches of 2x2
-You choose how many branches the turtle will mine
-You choose how deep the branches will be
- You can enable the "dropOff" option (what it does? :
SpoilerWhen the turtle finishes a branch , he will come back to the block he was standing at the begining and he will drop all of hes items and then if he has more branches to mine he will resume hes mining

You can use the "dropOff" option with RedpowerBuildcraftPowercraft to automate all of the mining the turtle does

The code:

Spoilerfunction check()
j=true
while j do
if turtle.detect() then
turtle.dig()
sleep(1)
else
j=false
end
end
end


function checkUp()
j=true
while j do
if turtle.detectUp() then
turtle.digUp()
sleep(1)
else
j=false
end
end
end


function ko1()
check()
turtle.forward()
checkUp()
turtle.turnLeft()
check()
turtle.forward()
checkUp()
turtle.turnRight()
end

function ko2()
check()
turtle.forward()
checkUp()
turtle.turnRight()
check()
turtle.forward()
checkUp()
turtle.turnLeft()
end


function branch(m,lengthM)

while (m<lengthM) do
ko1()
ko2()
m=m+2
end

turtle.turnLeft()
sleep(0.5)
turtle.forward()
sleep(0.5)
ko1()
ko2()
ko1()
ko2()
turtle.turnLeft()
sleep(0.5)
turtle.forward()
m=0
while m<(lengthM-2) do
ko1()
ko2()
m=m+2
end
check()
turtle.forward()
check()
turtle.forward()
end
br=1
dist=0

write(" tunnel or branches (1- Tunnel ,2- Branches )")
print(newline)
choice=read()
print(newline)
if (choice=='2') then


write("Enter how mant Branches you want ")
print(newline)
length=read()
length=tonumber(length)
print(newline)

write("Enter the length of the Branches (Even Number)")
print(newline)
lengthM=read()
lengthM=tonumber(lengthM)
if lengthM<2 then lengthM=2 end

write("Do you want dropOff? ( yes or no)")
print(newline)
dropOff=read()

m=0
n=0
loko=true
turtle.turnRight()


while n<length do

turtle.forward()




branch(m,lengthM)
br=1
n=n+1
dist=dist+5


if dropOff=='yes' then

turtle.turnLeft()
for i=1, dist do
turtle.forward()
end

for i=1 , 9 do
turtle.select(i)
turtle.drop()
end

if n<length then

turtle.turnLeft()
turtle.turnLeft()

for i=1, dist do
turtle.forward()
end
turtle.turnLeft()
end

end




if n<length then
turtle.forward()
branch(m,lengthM)
br=2
n=n+1
dist=dist-5






if dropOff=='yes' then
turtle.turnRight()
for i=1, dist do
turtle.forward()
end

for i=1 , 9 do
turtle.select(i)
turtle.drop()
end

if n<length then
turtle.turnLeft()
turtle.turnLeft()

for i=1, dist do
turtle.forward()
end
turtle.turnRight()
end

end
end

if br==2 then
if n<length then


turtle.turnLeft()
for i=1, 8 do
turtle.forward()
end
dist=dist+8
turtle.turnRight()

else if (not dropOff=='yes') then turtle.turnRight()
for i=1 , dist do
turtle.forward()
end
end
end
end


end
end


if choice=='1' then
write("Enter the length of the tunnel ")
print(newline)
oreh=read()
oreh=tonumber(oreh)

write("Do you want dropOff? ( yes or no)")
print(newline)
dropOff=read()


h=0
while h<oreh do
h=h+1
check()
turtle.forward()
checkUp()
turtle.turnLeft()
check()
turtle.up()
check()
turtle.turnRight()
turtle.turnRight()
check()
turtle.down()
check()
turtle.turnLeft()
end
h=0
turtle.turnLeft()
turtle.turnLeft()
while h<oreh do
turtle.forward()
h=h+1
end

if dropOff=='yes' then
for i=1 , 9 do
turtle.select(i)
turtle.drop()
end
end

end


Enjoy :]

Post bugs here and new ideas to add

edit1: fixed a small bug that didnt let the turtle continue more then 2 branches

edit2: minor bug fixed - when the turtle finished the branches and dropOff was on , the turtle went a few blocks away from the place he droped hes loot
shaunie1996 #2
Posted 25 March 2012 - 11:13 PM
How exactly would someone go about allowing this to be rednet activated? just starting on the mod and loving the possibilities :o/>/> picturing me at pc playing minecraft at pc in game controlling robots :o/>/>
any help appreciated

Edit: just played with it and realised it knocks off torches. anyway to work around this?
HTxL #3
Posted 26 March 2012 - 01:42 AM
I can actullay do a feature that will be placing torches every few blocks
I thought about it but you can also after it finished mining go and mine the rest of the ores that are 100% visible to you now
and on the way place torches , the only problem with that is monsters spawning in the dark.
So I guess I will add this feature

and I didnt really use the rednet thing so I dont really know yet how to program things with it so I will look into it
shaunie1996 #4
Posted 29 March 2012 - 08:51 PM
thanks for the quick response, just poking around atm to see how to go about the whole auto-mining start thing :o/>/> rp2 transposer ftw