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

Comprehensive Strip Miner

Started by Blueberrys, 18 March 2015 - 01:11 AM
Blueberrys #1
Posted 18 March 2015 - 02:11 AM
Update - 2016, April 9: I am no longer maintaining this code. If you wish to contribute to, or manage, the program/code, the best option would be to use github's pull request features. You may send me a PM or reply in this thread, but I can't guarantee I'll read it any time soon. See the licence information below if you want to do something a little different.
Side note: I've realized the name BlueAPI is too common and has been used before. To clear up confusions, I created the one used by this program. The code can be found on Github.

Greetings.

This program mines shafts (strips) to help you find ores easily.

Notable features:
  • Smart movement algorithms to make sure it stays on track even if something gets in the way
  • Smart fuel/torch/items management
  • Configurable shaft size/spacing
  • Configurable aggressive (attack when blocked) and neat (place walls) behaviors
  • Cleans up and uses lava
  • Interactive UI with on-screen help
  • Creates a spiral staircase down to your selected altitude
  • Stores mined resources in chest
  • Auto updates
Use this command on your mining turtle to install:
pastebin run yFhYMM9c

Use this command to start it up:
Miner

Follow the built-in instructions

Suggestions, comments, and bug reports are welcome.

Enjoy!


If you want the old version which doesn't use BlueAPI, you can get it here:
Spoiler
v3.4
pastebin get DeWCTAgv Miner


Source:
SpoilerMiner (v 3.6.4) (With BlueAPI) (Github)
BlueAPI (Github) (Not to be confused with the various other "blueapi" libraries)
Miner (v3.4) (Without BlueAPI) (Pastebin)

Update log:
SpoilerVersion 3.0
  • Release
Version 3.2
  • Ability to easily add items to fuel whitelist
  • Fixed bug where bot would throw away buckets or chests
  • Small efficiency fixes
Version 3.3
  • Fixed bug where duplicate items were added to the fueling whitelist
Version 3.4
  • Fixed bug where turtle breaks torch during stairs setup
Version 3.6.3
  • Now uses BlueAPI
  • Moved to github
  • Auto updates
  • Fixed alias on startup

Future plans:
Spoiler
  • Session persistence
  • Move to github (done)
  • Auto update (done)

Licence:
SpoilerFor anyone interested, feel free to copy/modify/use the code however you wish, including in your own projects. Please include appropriate attribution with links so everyone can benefit from them.
Legally equivalent to CC Non-commercial Attribution licence.

- Blueberrys
The Lone Wolfling #2
Posted 18 March 2015 - 11:37 AM
Your fueler should check if you can actually fuel with things, rather than just using a whitelist. (A whitelist is good as an option, but not necessarily the only thing to use. A blacklist may be better…)

You can still check how much of that item you'd need by checking the item count before refueling, and dividing appropriately to come up with the fuel value of the item.
Blueberrys #3
Posted 19 March 2015 - 05:51 AM
I did consider using the refuel function and passing 0 to test for fueling items (and even implemented something like that in an earlier version) but I settled with a whitelist for a couple reasons. I can accurately estimate the fuel level without consuming any items, and it flows better with the bot's current item management system. I'd think that most people would have one or two types of fueling items that they use often as opposed to a variety of different items.

Though, I do think the whitelist is currently very limited, I'll expand it to include all vanilla CC fueling items. Perhaps some way to add items to the whitelist would be good too.

Are there any other benefits which I might not have considered in using one of those alternates?

Edit: Included an option for adding items to the fuel whitelist. (v3.2)
Edited on 19 March 2015 - 05:09 PM
darkcammo #4
Posted 22 March 2015 - 09:39 PM
Great program!! I did notice a bug where it placed a torch and then broke the block it placed the torch on while making the spiral staircase. Other than that, very useful.
Blueberrys #5
Posted 23 March 2015 - 05:21 AM
Great program!! I did notice a bug where it placed a torch and then broke the block it placed the torch on while making the spiral staircase. Other than that, very useful.
Thanks for the feedback! I've come across that bug too, but didn't get around to fixing it yet.
Andd.. just made a quick update, it should be fixed now. (v3.4)
Mr_Tosti_III #6
Posted 29 March 2015 - 10:31 AM
I need some help loading this thing. When I do the ''pastebin run'' part it says string:68 attempting to index ? (n il value) and string:48 attempting to index ? (n il value)
Thanks in advance
Blueberrys #7
Posted 30 March 2015 - 12:41 AM
I need some help loading this thing. When I do the ''pastebin run'' part it says string:68 attempting to index ? (n il value) and string:48 attempting to index ? (n il value)
Thanks in advance
Hmm. I just tried it myself right now and it worked fine. It might be related to http not working right. Just try it again?
Mr_Tosti_III #8
Posted 30 March 2015 - 01:49 PM
I have tried several times, it keeps saying a nil value

I don't know know what this is and I am completely garbage at programming and all the languages. All I found on google were people talking about things I know nothing about.

Maybe this actually means something to you? found some threads on this forum but what they are talking about is outside my knowledge:
http://www.computercraft.info/forums2/index.php?/topic/12698-luaerror-attempt-to-index-a-nil-value/
http://www.computercraft.info/forums2/index.php?/topic/2065-attempt-to-index-a-nil-value/

found the text below on google:

this error usually comes from trying to index a field on something that isn't a table, or nil. chances are that whatever is at Account when the error happens, isn't a table or userdata, but a built in type like a string or number.

i'd start with checking the type of whatever is in Account when you get that error, and going from there.

the two most common ways to see this error (that i know of) are below:

local t = { [1] = {a = 1, b = 2}, [2] = {c = 3, d = 4} }
– t[5] is nil, so this ends up looking like nil.a which is invalid
– this doesn't look like your case, since you check for
– truthiness in Account
print
(t[5].a)

the case you are probably experiencing, is most likely this one:

local t =
{
[1] = {a = 1, b = 2},
[2] = 15, – oops! this shouldn't be here!
[3] = {a = 3, b = 4},
}
– here you expect all the tables in t to be in a consistent format.
– trying to reference field a on an int doesn't make sense.
print
(t[2].a)
Blueberrys #9
Posted 30 March 2015 - 05:42 PM
stuff
Hmm, strange. Do you have http enabled? Does it say anything else before that error, or does it come directly after you enter "pastebin run yFhYMM9c"? Can you provide a screenshot please?

I know what the error means, but I don't know where to find the source for string.lua. It would be kinda difficult to trace it down unless I have that or I can replicate the error myself.
Mr_Tosti_III #10
Posted 30 March 2015 - 07:47 PM
HTTP is enabled.

Here is the screenshot: hope you can see it. Otherwise here is a link https://www.dropbox.com/s/h39okznyw28r50r/Schermafdruk%202015-03-30%2020.45.29.png?dl=0

Blueberrys #11
Posted 30 March 2015 - 08:32 PM
stuff
I've made a few changes at that area, see if it fixed it?

If it still doesn't work, please make sure you have github.com and githubusercontent.com allowed in your config.
Mr_Tosti_III #12
Posted 30 March 2015 - 08:44 PM
Now I am getting this ^^
How do I allow that? I can't seem to find the right file where those settings can be allowed.

https://www.dropbox.com/s/mjba0589lkmie5g/Schermafdruk%202015-03-30%2021.43.33.png?dl=0
Blueberrys #13
Posted 30 March 2015 - 08:52 PM
stuff
Yep, seems to be the http messing up.

"..\.minecraft\config\ComputerCraft.cfg"
There are comments in the file explaining how to change it.
Mr_Tosti_III #14
Posted 30 March 2015 - 08:59 PM
This is what it says in the ''computercraft'' server config file. There is no config map in my appdata/roaming/.minecraft

general {
# The disk space limit for computers and turtles, in bytes
I:computerSpaceLimit=2097152

# Enable the "http" API on Computers
B:enableAPI_http=true
Blueberrys #15
Posted 30 March 2015 - 11:38 PM
.
And this?

S:http_whitelist=*
Avarion #16
Posted 05 March 2016 - 11:59 AM
Does not work for me. b_update causes a crash in line 67. Attempt to compare __lt on nil and nil
insuusvenerati #17
Posted 20 March 2016 - 03:44 AM
Sorry for a noob question but how do I get blue API to work? I can only find one thing in Google and it links to a post here with a pastebin but after getting it and executing it I'm still getting the error that BlueAPI doesn't exist.
DeepHeart #18
Posted 02 April 2016 - 11:37 PM
Thankyou Blueberrys: love your excellent strip_miner. I have used it a lot in MC. However I have had to use the version (3.4) without the API, as the BlueAPI one won't work. The pastebin downloads OK, and runs, which I then downloads several folders and files, but no Miner program, and an error saying it requires "BlueAPI"

I will look on gitHub as your update log says you have switched to it (from pastebin).

I had a look at some of your code. It does justify "comprehensive"! Do you allow people to use sections of your code, and then share the resulting programs on forums like this etc?
Blueberrys #19
Posted 09 April 2016 - 05:10 AM
Does not work for me. b_update causes a crash in line 67. Attempt to compare __lt on nil and nil
Try deleting the files associated with the Miner and BlueAPI and try again.
If that doesn't work, try using the older version:
pastebin get DeWCTAgv Miner

BlueAPI
To everyone having issues with BlueAPI not installing correctly, it's likely due to HTTP being disabled. Enable it and try again.
Alternately, use the older version which doesn't use the API:
pastebin get DeWCTAgv Miner

Do you allow people to use sections of your code, and then share the resulting programs on forums like this etc?
Yep, you may; "…copy/modify/use the code however you wish, including in your own projects. Please include appropriate attribution with links so everyone can benefit from them. Legally equivalent to CC Non-commercial Attribution licence."
Edited on 09 April 2016 - 12:53 PM