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

Vertical shaft (rabbit hole) ore miner

Started by access_denied, 02 January 2013 - 08:38 PM
access_denied #1
Posted 02 January 2013 - 09:38 PM
Hello!

First of all, I want to say that this script is heavily inspired from this one, written by eonsv. However, I had a few problems with it, such as it requiring ender chests to operate, so I wrote this from scratch.

Features

What it basically does is it digs this pattern to bedrock. (The shafts shown in the picture are two blocks deep, just for testing purposes. The dimensions are 8x8)
The script can be stopped and has an option to be resumed. Screenshots.
When the turtle detects an interesting block (e.g. an ore) in an adjacent block, it will mine it. Screenshots.
It is fuel efficient. It will get the exact number of fuel it needs to process the next shaft when docked.

Download

http://pastebin.com/Mj1H7sMF

How to use

Start off with building this (this is the dock). The top chest is for fuel. The back chest is for output.
Next, retrieve the pastebin file with pastebin get or manually placing it into your turtle's program folder. Name the program "dig". Don't forget to set your turtle's label, because then it won't lose the program and persistence when broken!
After you've done that, run the program and follow the wizard.

Explanation of some things in the config screen (important, please read):

Width is the number of blocks it will go right.
Height is the current Y coordinate of the turtle! You can get it by looking at the number in brackets in Rei's minimap.
Length is the number of blocks it will go forward.
Number of excluded blocks is the number of blocks that you do not want to mine, e.g. stone and dirt (stone and sandstone in my test world, because the world is sandstone)
Fuel units per item is the number of computercraft fuel units the turtle will get out of a single fuel item (e.g. coal gives 80 fuel units).

Changelog
  • V1.4.1: Fixed emptying out treasure chests!
  • V1.4: Added support for emptying chests. Improved inventory management.
  • V1.3: Perfected position tracking system. Now desync of position/direction should be much much much rarer. Added startup script prompt.
  • V1.2: Added prompt to cancel resume (e.g. you want to move the turtle, but it starts up and resumes, now it allows you to cancel for 10 seconds before moving!)
This is a WIP, as I will be adding support for multiple turtles, monitoring over rednet, etc… Please report any bugs :)/>

Hopefully you will find this useful!

License:

Do whatever you want with the script, but give credit to people who wrote it and keep this license. Simple, right?
Kane Hart #2
Posted 02 January 2013 - 09:54 PM
This looks pretty darn sweet.


0 Fuel
1 excluded block
2 excluded block 2 etc?

It seems good I did like the other one with ender chest support a bit only because I use it myself but this one seems like it will be pretty darn good still.

Also I was wondering can I do this say at level 60? I assume it can still do this grid pattern say underground so I can leave the surface pretty?

Thanks again I can't wait to give this a try. One thing I would like to see and I'm 100% newbie is maybe a special startup script where it surfaces some how if the chunks unload/server reboot and etc. Kind sucks trying to track her down again.

Thanks!
access_denied #3
Posted 02 January 2013 - 10:10 PM
This looks pretty darn sweet.


0 Fuel
1 excluded block
2 excluded block 2 etc?

It seems good I did like the other one with ender chest support a bit only because I use it myself but this one seems like it will be pretty darn good still.

Also I was wondering can I do this say at level 60? I assume it can still do this grid pattern say underground so I can leave the surface pretty?

Thanks again I can't wait to give this a try. One thing I would like to see and I'm 100% newbie is maybe a special startup script where it surfaces some how if the chunks unload/server reboot and etc. Kind sucks trying to track her down again.

Thanks!

Yes, that's right. Is the reminder clear enough? I am not very good at being clear XD

Yes, you can start at any level!

Hmm, I thought turtles don't start up when the chunk loads… Am I wrong?

EDIT: I WAS wrong! Holy shit, I am going to write the resume-on-startup now.

EDIT 2: Added support for automatic resuming, although it may result in your turtle getting lost!
Kane Hart #4
Posted 02 January 2013 - 10:43 PM
Sweet, I never did a startup script before not sure if I need to but woot :)/>
access_denied #5
Posted 03 January 2013 - 02:01 AM
Proper support of startup scripts is done and released! Now the turtles shouldn't lose the last operation done before the chunk unloading/shutdown/w.e. so rebooting is much more stable.
Kane Hart #6
Posted 03 January 2013 - 08:26 PM
One thing I dislike is this can't loot dungeon chests from what I can tell. Would this be possible to add chest support to do just this?
access_denied #7
Posted 03 January 2013 - 08:34 PM
One thing I dislike is this can't loot dungeon chests from what I can tell. Would this be possible to add chest support to do just this?

Hmm, yes. Although dungeon chests usually never contain anything good anyway :)/>

I'll add it.
Kane Hart #8
Posted 03 January 2013 - 10:06 PM
One thing I dislike is this can't loot dungeon chests from what I can tell. Would this be possible to add chest support to do just this?

Hmm, yes. Although dungeon chests usually never contain anything good anyway :)/>

I'll add it.

Thanks, We have portal gun installed and a few other mods that actually add some unique loot like steadfast bee and new saplings from forestry. For Portal gun you can get a gun or black hole and even few other things. Overall its not bad. Another miner did that and I thought it was pretty cool hehe.
sublightnova #9
Posted 04 January 2013 - 02:12 AM
Very nice program… I was trying a few different other mining programs but all failed at some point. Your's hasn't so far… It does the job and seems to do it very well… The resume is very nice as well as being able to specifiy the dimensions. If the turtle finds diamonds i usually drop down the shafts and inspect the walls myself to see if it missed any diamonds (after the turtle finished its program)… I usually mine all over the place, that is why :)/>

One thing I was thinking about. It is sometimes very hard to see where your turtle (any turtle) has been once it is fiinished. Setting up a new run requires manual work counting blocks.. Wouldn't it be awesome if the turtle would place down say.. landmarks on the corners where it has been? Or have it move to a clean area left of the dug out area to a spot that was specified by the dimensions. So you only have to refuel it and start it again.. Instead of axing the block and setting it up again.

Maybe i'll implement this myself at some point if everyone finds this a silly idea. I might even go so far as sort of creating a preview area and sort of shows the radius in which the turtle is going to mine linke with the quarry. However i think the turtle is a bit too limited even though you can obviously have it set down landmarks. Ah well. nvm me just rambling outloud. :)/>

Anyways, keep up the good work!
access_denied #10
Posted 04 January 2013 - 02:19 AM
One thing I dislike is this can't loot dungeon chests from what I can tell. Would this be possible to add chest support to do just this?

Hmm, yes. Although dungeon chests usually never contain anything good anyway :)/>

I'll add it.

Thanks, We have portal gun installed and a few other mods that actually add some unique loot like steadfast bee and new saplings from forestry. For Portal gun you can get a gun or black hole and even few other things. Overall its not bad. Another miner did that and I thought it was pretty cool hehe.

Added! It was a 3 line change, hehehe! Thank you for your suggestion.
Kane Hart #11
Posted 06 January 2013 - 08:34 PM
One thing I dislike is this can't loot dungeon chests from what I can tell. Would this be possible to add chest support to do just this?

Hmm, yes. Although dungeon chests usually never contain anything good anyway :)/>

I'll add it.

Thanks, We have portal gun installed and a few other mods that actually add some unique loot like steadfast bee and new saplings from forestry. For Portal gun you can get a gun or black hole and even few other things. Overall its not bad. Another miner did that and I thought it was pretty cool hehe.

Added! It was a 3 line change, hehehe! Thank you for your suggestion.

Thanks for adding it :)/>
CrazylikE #12
Posted 08 January 2013 - 12:58 PM
After mining for 0-5 seconds it outputs

"Press Enter to exit…parallel:22:dig:113: attempt to index ? (a nil value)"

I have fuel in slot 0 and the 3 next slots excluded, hight set to 60, width at 8. Tried it ten times now, always fails on me. Also, I thought it was supposed to mine straight down and only mine to the side if there was ore there, but it seems to mine the sides no matter what.
access_denied #13
Posted 08 January 2013 - 09:27 PM
After mining for 0-5 seconds it outputs

"Press Enter to exit…parallel:22:dig:113: attempt to index ? (a nil value)"

I have fuel in slot 0 and the 3 next slots excluded, hight set to 60, width at 8. Tried it ten times now, always fails on me. Also, I thought it was supposed to mine straight down and only mine to the side if there was ore there, but it seems to mine the sides no matter what.

Execute "rm digpersist", should fix it. The problem is that the turtle was shut down while it was saving its state, resulting in an empty file. This is why nobody should ever do Thread.stop().
Someguy123 #14
Posted 09 January 2013 - 06:23 AM
I love you man, the automatic startup script works amazingly, finally a miner which doesn't break after its chunk gets unloaded or my server restarts.
access_denied #15
Posted 09 January 2013 - 08:39 AM
I love you man, the automatic startup script works amazingly, finally a miner which doesn't break after its chunk gets unloaded or my server restarts.

Thank you! However, it will still fail in some cases. But I can't prevent that because of how Computercraft is written.
access_denied #16
Posted 09 January 2013 - 07:34 PM
Woups! Before 1.4.1 it didn't empty out adjacent chests, but that is fixed! Sorry for the inconvenience.
sublightnova #17
Posted 09 January 2013 - 09:50 PM
I love you man, the automatic startup script works amazingly, finally a miner which doesn't break after its chunk gets unloaded or my server restarts.

Thank you! However, it will still fail in some cases. But I can't prevent that because of how Computercraft is written.

You can put a chunk turtle (forgot the exact name) on the chunk which should prevent the chunk from unloading…. :)/>
Kane Hart #18
Posted 17 January 2013 - 01:03 AM
Sometimes I come back to my turtles and they have this error:
https://dl.dropbox.com/u/84010144/s/java%202013-01-16%2003-36-22-066.png
access_denied #19
Posted 17 January 2013 - 02:29 AM
Sometimes I come back to my turtles and they have this error:
https://dl.dropbox.c...3-36-22-066.png
This means that the turtle was interrupted while it was dumping its state. I am pretty sure Computercraft throws an exception to force terminate the script and that causes the file buffer not to flush.

Basically, I have no way of ensuring that the data will be written to disk.
Kris #20
Posted 02 April 2013 - 12:25 AM
Looks like the only ore finder program that actually works, thxn
I like the interface as well
Is there any option for it to send it's update to computer and computer to monitor ?
Edit: Wow i love how it dumps all the coal in the refuel chest, and takes only how much it needs for the next job,
Awsome program by far the best out there, i know ! i tried them all.
oxgon #21
Posted 06 April 2013 - 04:36 PM
Wish I could use this, so far getting "Press Enter to exit…parallel:22:dig:113: attempt to index ? (a nil value)" all the time :(/>
wakafanykai123 #22
Posted 18 May 2013 - 02:48 PM
Can you implement a option to use the old way to deposit in enderchests like the original program?
I just switched to this program from the old one and it is amazing!
airbus a320 #23
Posted 17 October 2013 - 02:14 PM
Maybe the best mining program!
elektronemulo #24
Posted 05 November 2014 - 10:30 AM
I love your program and I use it pretty heavily.

Suggestion for more efficient scanning: Since your program averages 2 blocks examined for each move (4 blocks per move on the way down, 0 blocks per move on the way up), wouldn't it be more efficient to dig a different shaft on the way up? So, on the way down, the turtle would examine right, back, left, move down, and examine left back right. At the bottom the turtle would dig forward 1, and follow a similar scanning pattern on the way back up.

I second the motion for optional enderchest usage for both a dumpchest and a fuel chest. (Once the player has reached the ability to provide enderchests to the turtle, this would save fuel.)

Also, could you add a command line parameter to allow for flat bedrock worlds so that the turtle will dig until it can't dig further rather than stopping at layer 6?

Finally, could you add an option to fill in the top of the hole so to prevent users from falling in? :-D (I personally fill in the top three layers with cobble.)
Buho #25
Posted 24 November 2014 - 02:51 PM
This is similar to my tried-and-true mining program that I've been using for over a year. It digs a "rabbit hole" down, checks all walls, until it hits bedrock. Then it moves up 5, forward 5, down to bedrock (to account for the "roughness" of bedrock), and then digs up to the surface (or starting level), checking all walls. At the surface, it moves forward 5 and repeats until a specified distance is reached. Then it moves over one, shifts forward or back (to create the offset pattern) and returns. It then shifts right again, forward or back (for the pattern), and repeats.

At the beginning I specify the dimensions of this mining field. I typically specify 10x80 with other turtles running in parallel. A top chest for fuel is not needed since in the overworld it can refuel with found coal. I don't have ender chests that are usable for turtles, so it returns back to that first chest when there is less than two slots free. Transmission of progress through rednet allows me to monitor them from a central computer.

The biggest problem with my program is retrieving turtles after Minecraft crashes. I'm recording position and direction for such an event, so they can come home from the depths of the ground, but it seems Minecraft loves to crash between the writing to file and the turtle.turnRight(). GPS is unpractical since I'm usually deploying from y=16 and don't want to poke holes in the ceiling to launch a GPS array.

The second biggest problem with my program is setup. Setting the initial position, inventory, and command-line parameters is time-intensive when you have 16 running in parallel. I'm working on a deployment program from a master computer to automate this setup.