Jump to content




Stair Mining Tool (With Distance Input) - For N00bs

turtle api computer

20 replies to this topic

#1 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

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.. :/

Attached Files



#2 Ulthean

  • Members
  • 171 posts

Posted 18 December 2012 - 10:03 PM

Good job, keep it up!

(PS: there is nothing wrong with your explanation)

#3 ChunLing

  • Members
  • 2,027 posts

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.

#4 Learning_inpaired

  • New Members
  • 77 posts

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)

#5 ChunLing

  • Members
  • 2,027 posts

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 by ChunLing, 19 December 2012 - 04:01 PM.


#6 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 20 December 2012 - 11:56 PM

View PostLearning_inpaired, on 19 December 2012 - 03:39 PM, said:

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)

View PostChunLing, on 19 December 2012 - 04:00 PM, said:

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.

#7 ChunLing

  • Members
  • 2,027 posts

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.

#8 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 22 December 2012 - 03:18 PM

View PostChunLing, on 21 December 2012 - 01:33 AM, said:

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. ;)

#9 ChunLing

  • Members
  • 2,027 posts

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.

#10 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 22 December 2012 - 09:07 PM

View PostChunLing, on 22 December 2012 - 05:06 PM, said:

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

#11 ChunLing

  • Members
  • 2,027 posts

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.

#12 Doyle3694

  • Members
  • 815 posts

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.

#13 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 24 December 2012 - 08:18 PM

View PostDoyle3694, on 22 December 2012 - 11:20 PM, said:

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().

#14 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 25 December 2012 - 09:39 PM

Bump to the top

#15 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 26 December 2012 - 10:07 PM

Anyone see any problems that need clearing up?

#16 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 01 January 2013 - 08:10 PM

Hopefully this gets noticed.

#17 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 02 January 2013 - 05:20 PM

Come onn. No one cares. :L

#18 Ulthean

  • Members
  • 171 posts

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)


#19 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 03 January 2013 - 06:52 PM

View PostUlthean, on 03 January 2013 - 01:44 AM, said:

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

#20 Ulthean

  • Members
  • 171 posts

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users