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

3x3 tunnel

Started by svennp, 29 February 2012 - 01:45 PM
svennp #1
Posted 29 February 2012 - 02:45 PM
If you didn't already understand that this is for the turtle, it is.
the title says what it does, it mines a 3x3 hole the way its facing for as long as you set it to. (long = blocks, not a timer)
i did a rewrite of the whole script using functions and more loops.
should be a bit better now i think :unsure:/>/>/>
now it can handle more sand and gravel too, and returns to starting position when done

video:
Spoiler

[media]http://youtu.be/_Gq-7UW6ldw[/media]


the new script:
http://pastebin.com/vSWz3kdk


the old script (DON'T USE!):
Spoiler

print "input lenght of the 3X3 tunnel"
n2 = io.read()
n1 = 0
n2 = tonumber(n2)
n3 = 0
shell.run("clear")
while true do
shell.run("clear")
print ("turtle will stop when the number reaches zero: "..n2)
print ""
print "or if theres no more space in turtle's inventory"

turtle.dig()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digUp()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digUp()
turtle.digUp()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digUp()
turtle.digUp()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
n3 = n3 + 1
n2 = n2 - 1
shell.run("clear")
print (n2)
if n1 == n2 then
break

elseif turtle.getItemCount(9) ~= 0 then
break
end
end

repeat
shell.run("clear")
print "returning to start position"
turtle.back()
n3 = n3 - 1
until n3 == 0
print "DONE!"

Hope you like it!
Ponder #2
Posted 01 March 2012 - 07:53 PM
Looks nice, but I'd advice you to try to put the whole digging part in the middle in a separate loop or a function. It'd make your code a little bit tidier and nicer.
Tassadar12345 #3
Posted 10 July 2012 - 06:55 PM
Nice, I am a shaft miner using redpower and computercraft so this is a great script for my automated mine.

Looks nice, but I'd advice you to try to put the whole digging part in the middle in a separate loop or a function. It'd make your code a little bit tidier and nicer.

He is right.
timboiscool #4
Posted 11 July 2012 - 11:46 AM
i suggest you put it in the subforum turtle programs.

on-topic: looks good.
FireKave #5
Posted 23 December 2012 - 02:49 AM
i get an error on line 42 bios:338: [string "Tunnel"]:42: '=' expected

edit; i fixed it:) i just copy/pasted your script after i had typed the script mannualy myself