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

Stair Mining Tool (With Distance Input) - For N00bs

Started by De Tronazox, 17 December 2012 - 12:05 PM
De Tronazox #1
Posted 17 December 2012 - 01:05 PM
This is my first program. Its fairly simple, and didn't take long to do. Even if you have the smallest understanding of the turtle API you should be able to understand this.



print("How far?")
dist= (read())
for i = 1, dist do
			 turtle.up()
			 turtle.up()
			 turtle.up()
			 turtle.dig()
			 turtle.forward()
			 turtle.digDown()
			 turtle.down()
			 turtle.digDown()
			 turtle.down()
			 turtle.digDown()
			 turtle.down()
			 turtle.digDown()
			 turtle.down()
end 

How do I use this?!?!

Save the code, to do this:
1. Right-click on the turtle.
2. Type: edit stairs – This will edit the file "stairs" (Lua is case sensitive!!) and create the file if it doesn't exist.
3. Type the code in line by line.
4. Press "Ctrl" and save the file, and then exit.
5. On the main screen, type "stairs" to run the stairs program you just created. It will ask you: "How far?" and then you can input how far you would like the turtle to mine, and press ENTER.


Now, what does it do?

Firstly, it prints "How far?", and then reads the input and sets it as dist. Now, if you left it as:
 read() 
it would read it as a string, hence the other brackets.

 for i = 1, dist do 
Tells the computer that every i = +1, and it will do until i reaches dist, which we set when it reads the input.

Sorry if that was a bad explanation, but I tried >.<.

You can download the .txt with the code, but it wont allow me to upload the actual file.. :/
Ulthean #2
Posted 18 December 2012 - 10:03 PM
Good job, keep it up!

(PS: there is nothing wrong with your explanation)
ChunLing #3
Posted 19 December 2012 - 01:30 PM
You can just use digUp and digDown a bit more so you don't have to move up and down so much.
Learning_inpaired #4
Posted 19 December 2012 - 03:39 PM
or you can craft and place a turtle at some random level under ground and simple type
tunnel 64
the program name and then the distance
But as for your program there, it looks nice outher then the fact that it goes stright down… some noob will most likly jump down the hole and die (i have done this many times)
ChunLing #5
Posted 19 December 2012 - 04:00 PM
It only goes down four at a time, then goes up three and forward one. That makes a staircase, not a vertical shaft.

Also, I dig vertical shafts all the time, right to bedrock. You just fill the bottom with water or something.
Edited on 19 December 2012 - 03:01 PM
De Tronazox #6
Posted 20 December 2012 - 11:56 PM
or you can craft and place a turtle at some random level under ground and simple type
tunnel 64
the program name and then the distance
But as for your program there, it looks nice outher then the fact that it goes stright down… some noob will most likly jump down the hole and die (i have done this many times)
It only goes down four at a time, then goes up three and forward one. That makes a staircase, not a vertical shaft.

Also, I dig vertical shafts all the time, right to bedrock. You just fill the bottom with water or something.

Uhm, the program IS called StairMining Tool… Haha

It's meant to go in a stair fashion, and for those people (like me) who hate 3 high stair cases, welp, I made it 4 high.
ChunLing #7
Posted 21 December 2012 - 01:33 AM
Yes, but if you use both digUp and digDown, you get a four block high staircase with just moving forward and down, you don't have to go back up at all. Just an efficiency/speed thing.
De Tronazox #8
Posted 22 December 2012 - 03:18 PM
Yes, but if you use both digUp and digDown, you get a four block high staircase with just moving forward and down, you don't have to go back up at all. Just an efficiency/speed thing.
Fair enough, I just thought it looked simpler to the newby eye. ;)/>
ChunLing #9
Posted 22 December 2012 - 05:06 PM
Possibly. Let's see:
turtle.digUp()
turtle.digDown()
for i = 1, dist do
    turtle.dig()
    turtle.forward()
    turtle.digUp()
    turtle.digDown()
    turtle.down()
    turtle.digDown()
end
Hmm…it's not so much a matter of coding experience, I think this version is just a tad harder to visualize.

It digs a lot faster, though.
De Tronazox #10
Posted 22 December 2012 - 09:07 PM
Possibly. Let's see:
turtle.digUp()
turtle.digDown()
for i = 1, dist do
	turtle.dig()
	turtle.forward()
	turtle.digUp()
	turtle.digDown()
	turtle.down()
	turtle.digDown()
end
Hmm…it's not so much a matter of coding experience, I think this version is just a tad harder to visualize.

It digs a lot faster, though.

To the newby eye
ChunLing #11
Posted 22 December 2012 - 11:13 PM
Eh…I'm sure that "shorter" == "simpler" to the real newby eye. Your version was easy for me to visualize working, while I needed to check my version using a visualization aid. So there's that.
Doyle3694 #12
Posted 22 December 2012 - 11:20 PM
also, those brackets around read do nothing. if you really wanted to be proper, you could use tonumber(), but after all, lua is userfriendly enough to make it's for loops do it for you.
De Tronazox #13
Posted 24 December 2012 - 08:18 PM
also, those brackets around read do nothing. if you really wanted to be proper, you could use tonumber(), but after all, lua is userfriendly enough to make it's for loops do it for you.

I've come to realize this, and you use tonumber read() not tonumber().
De Tronazox #14
Posted 25 December 2012 - 09:39 PM
Bump to the top
De Tronazox #15
Posted 26 December 2012 - 10:07 PM
Anyone see any problems that need clearing up?
De Tronazox #16
Posted 01 January 2013 - 08:10 PM
Hopefully this gets noticed.
De Tronazox #17
Posted 02 January 2013 - 05:20 PM
Come onn. No one cares. :L
Ulthean #18
Posted 03 January 2013 - 01:44 AM
What is there to say? It just digs a staircase, in most cases the program is functional, and that's it.
Easy improvements could be:
  • Gravel-proofing it
  • Allowing it to place torches every X blocks
  • Making sure there is a block at the bottom of each step. (if you dig through a cave in this version you might fall)
  • Allowing it to place actual stairs (on the way back up)
  • Allowing it to dig out the walls and replace it with other block-types (for example: I want sandstone walls)
De Tronazox #19
Posted 03 January 2013 - 06:52 PM
What is there to say? It just digs a staircase, in most cases the program is functional, and that's it.
Easy improvements could be:
  • Gravel-proofing it
  • Allowing it to place torches every X blocks
  • Making sure there is a block at the bottom of each step. (if you dig through a cave in this version you might fall)
  • Allowing it to place actual stairs (on the way back up)
  • Allowing it to dig out the walls and replace it with other block-types (for example: I want sandstone walls)
SIMPLE program for beginners. That's the whole point of these tut's.
But I could do that, yes
Ulthean #20
Posted 04 January 2013 - 12:14 AM
In this case, you could start of with a basic, easy-to-understand program and then upgrade it along the way.
De Tronazox #21
Posted 04 January 2013 - 05:35 PM
In this case, you could start of with a basic, easy-to-understand program and then upgrade it along the way.
Pretty much what i'm doing. ;)/>