3057 posts
Location
United States of America
Posted 25 July 2014 - 04:37 PM
What it does1. Refuels using external lava source, if encountered in the mining process.2. Allows a certain amount of time to be spent mining.3. Checks the inventory constantly to prevent ore from being mining but not collected.4. Returns to base when: -Out of Fuel -Out of Space -Mining time is up5. Drops all items into a chest at the start when finished.6. Mines recursively to extract every piece of ore possible.7. Identifies ore by comparing it to "waste" blocks in it's inventory ( stone, dirt, sand, gravel) -Pro: Can be easily used in a modpack -Con: Will identify wood/chests/etc. as ore if it runs into it.8. Standard branch mining procedure, leaves 3 blocks between branches.9. Constantly reduces the waste items stacks to a single item, preventing gravel/dirt/sand from overwhelming the turtles inventory.10. Logs it's progress on screen and in a file named "turtleLog"11. NEW! Turtle now senses the amount of waste blocks you've added to it's inventory.12. NEW! Turtle will now detect chests & other inventories! (credit to Mirodin for some advice)Set up1. Place a chest down on the level you want to mine (I suggest ~10) and place the turtle immediately on top of it.2. Place any amount of waste blocks in the top slots (1 - ?) of the turtle's inventory. (I suggest placing stone (not cobblestone) in the first slot, for maximum efficiency time-wise, and limiting the amount of waste blocks as much as possible. If you know the area the turtle will be mining in, you should adjust your blocks accordingly (eg. if there is an abundance of obsidian that you don't want, add that in.)3. Place an empty bucket in slot 15, and any fuel you wish the turtle to use in slot 16.4. Download the turtle mining script: pastebin get ZpKSLTgW*
5. Run the script with the proper command line arguments. Here are some examples: -miner 1 hours
+Runs for 1 hour, note you
must use "hours" instead of "hour"
1 -miner 1 hours 15 minutes
+Runs for 1 hour, 15 minutes. Again note you must use the plural version regardless if the number is singular.
1 -miner 15 minutes 10 seconds
+Runs for 15 minutes, 10 seconds
1Update: I may have fixed this (with pattern magic) to completely ignore the "s" at the end. Please report any issues found with this system.
Problems Identified1. The turtle will mine mossy cobble, cobblestone, wooden planks, grass blocks, and dungeon chests thinking they are ore.2. The turtle will incorrectly identify lava in front of it, when in fact the lava is in front and down, due to the fact that the bucket will pick it up. Unfortunately, liquid is not detectable, and as such I cannot differentiate between the two. This has been fixed. For information on my fix, see the spoiler "detecting liquids"3. We'll have to see if any other problems come up, since I have not found any others.Downloadpastebin get ZpKSLTgW*
detecting liquids
I thought I might as well throw in the way I detect liquids.
turtle.select( empty_slot ) --#in my script, it checks slot 14, because 15 & 16 have stuff in them
if turtle.getItemCount( empty_slot ) == 0 and not turtle.compare() and not turtle.detect() then --#make sure there is nothing in the slot, then compare air with the block in front
turtle.select( bucket_slot ) --#in my script, this is slot 15
if turtle.place() then
--#aha, we have picked up some liquid
if turtle.refuel() then
--#the liquid was lava, and we refueled from it
--#my script will now continue checking for more lava... However yours might not have to
else
turtle.place()
--#i want to get rid of the liquid, since it wasn't lava
end
end
end
*note: the pastebin will remain the same throughout all versions of this program, and is set to never expire. If there is a download failure, it is most likely caused by pastebin being under heavy load. I reserve the right to change the code at any time without warning. If any bugs are identified, I will work on fixing them and update this topic accordingly.
Edited on 27 July 2014 - 01:45 PM
42 posts
Posted 25 July 2014 - 05:43 PM
Loving the fuel efficiency the most, and the keeping logs too!
-Pro: Can be easily used in a modpack
-Con: Will identify wood/chests/etc. as ore if it runs into it.
How about adding a table containing all the things it
needs to keep:
local keepTab = {oreIDHere, oreIDThere}
Overall though, great job!
7083 posts
Location
Tasmania (AU)
Posted 25 July 2014 - 05:47 PM
The problem is that the turtle cannot compare blocks in front of it according to their IDs, but rather only by the blocks it's already carrying. Reserving inventory slots for all possible blocks you might want to mine (or not mine) is out of the question.
3057 posts
Location
United States of America
Posted 25 July 2014 - 09:55 PM
Bomb Bloke is correct. However, if you are playing with terrain that has different things in it (such as the nether), you could change the blocks to something different (netherwract, soulsand, etc.) I may add an optional command line variable that controls the amount of slots you want to use up while mining.
154 posts
Location
London, England
Posted 25 July 2014 - 10:08 PM
Quite a neat way of doing that is to sense the first X slots with blocks in and then defining those as the waste blocks
3057 posts
Location
United States of America
Posted 25 July 2014 - 10:15 PM
Quite a neat way of doing that is to sense the first X slots with blocks in and then defining those as the waste blocks
Good idea, I'll try it.
Edit: Added this, please report any errors you encounter. I think I'll also add some checking for stuff that
should be in the turtle.
Edit of Edit: Added checking, turtle will now prompt you when it detects how many waste blocks you have, and if it detects no fuel source, as well as stopping if it is not given a bucket.
Edited on 25 July 2014 - 08:31 PM
33 posts
Posted 27 July 2014 - 03:19 PM
To return the favour for your help in my mining script and to resolve your issue with the dungeon chests. :)/>
I had a simple chest cleaning routine in my old quarry script which emptys chests before digging them. To use this you should maybe transfer your inventorycheck in a function which gets then called every single successful chest cleaning operation:
function chestCleaner()
while turtle.suckUp() do
inventoryCheck()
end
while turtle.suckDown() do
inventoryCheck()
end
while turtle.suck() do
inventoryCheck()
end
end
-- main
local stepmax = 16
for s=1, stepmax do
chestCleaner()
oreDetector()
inventoryCheck()
end
Cheers
3057 posts
Location
United States of America
Posted 27 July 2014 - 03:26 PM
To return the favour for your help in my mining script and to resolve your issue with the dungeon chests. :)/>/>/>
I had a simple chest cleaning routine in my old quarry script which emptys chests before digging them. To use this you should maybe transfer your inventorycheck in a function which gets then called every single successful chest cleaning operation:
function chestCleaner()
while turtle.suckUp() do
inventoryCheck()
end
while turtle.suckDown() do
inventoryCheck()
end
while turtle.suck() do
inventoryCheck()
end
end
-- main
local stepmax = 16
for s=1, stepmax do
chestCleaner()
oreDetector()
inventoryCheck()
end
Cheers
If I was to add any code, it would be to my already gigantic recursive check function… Thanks anyway.
Spoiler
function check( nLevel )
if not nLevel then
nLevel = 1
elseif nLevel > 200 then
return
end
if not ok then return end
--check for lava
turtle.select( 14 )
if turtle.getItemCount( 14 ) == 0 and not turtle.compare() and not turtle.detect() then
turtle.select( 15 )
if turtle.place() then
print( "[check]: Liquid detected!" )
if turtle.refuel() then
print( "[check]: Refueled using lava source!" )
turtle.forward()
check( nLevel + 1 )
while not turtle.back() do end
ignoredFuel = ignoredFuel + 2
else
print( "[check]: Liquid was not lava!" )
turtle.place()
end
end
end
--check for ore
if notwaste( turtle.compare ) then
print( "[check]: Ore Detected!" )
repeat turtle.dig() until turtle.forward()
print( "[check]: Dug ore!" )
check( nLevel + 1 )
while not turtle.back() do end
ignoredFuel = ignoredFuel + 2
end
if not ok then return end
turtle.turnLeft()
--check for lava
turtle.select( 14 )
if turtle.getItemCount( 14 ) == 0 and not turtle.compare() and not turtle.detect() then
turtle.select( 15 )
if turtle.place() then
print( "[check]: Liquid detected!" )
if turtle.refuel() then
print( "[check]: Refueled using lava source!" )
turtle.forward()
check( nLevel + 1 )
while not turtle.back() do end
ignoredFuel = ignoredfuel + 2
else
print( "[check]: Liquid was not lava!" )
turtle.place()
end
end
end
--check for ore
if notwaste( turtle.compare ) then
print( "[check]: Ore Detected!" )
repeat turtle.dig() until turtle.forward()
print( "[check]: Dug ore!" )
check( nLevel + 1 )
while not turtle.back() do end
ignoredFuel = ignoredFuel + 2
end
turtle.turnRight()
if not ok then return end
turtle.turnRight()
--check for lava
turtle.select( 14 )
if turtle.getItemCount( 14 ) == 0 and not turtle.compare() and not turtle.detect() then
turtle.select( 15 )
if turtle.place() then
print( "[check]: Liquid detected!" )
if turtle.refuel() then
print( "[check]: Refueled using lava source!" )
turtle.forward()
check( nLevel + 1 )
while not turtle.back() do end
ignoredFuel = ignoredFuel + 2
else
print( "[check]: Liquid was not lava!" )
turtle.place()
end
end
end
--check for ore
if notwaste( turtle.compare ) then
print( "[check]: Ore Detected!" )
repeat turtle.dig() until turtle.forward()
print( "[check]: Dug ore!" )
check( nLevel + 1 )
while not turtle.back() do end
ignoredFuel = ignoredFuel + 2
end
turtle.turnLeft()
if not ok then return end
--check for lava
turtle.select( 14 )
if turtle.getItemCount( 14 ) == 0 and not turtle.compareUp() and not turtle.detectUp() then
turtle.select( 15 )
if turtle.placeUp() then
print( "[check]: Liquid detected!" )
if turtle.refuel() then
print( "[check]: Refueled using lava source!" )
turtle.up()
check( nLevel + 1 )
while not turtle.down() do end
ignoredFuel = ignoredFuel + 2
else
print( "[check]: Liquid was not lava!" )
turtle.placeUp()
end
end
end
--check for ore
if notwaste( turtle.compareUp ) then
print( "[check]: Ore Detected!" )
repeat turtle.digUp() until turtle.up()
print( "[check]: Dug ore!" )
check( nLevel + 1 )
while not turtle.down() do end
ignoredFuel = ignoredFuel + 2
end
if not ok then return end
--check for lava
turtle.select( 14 )
if turtle.getItemCount( 14 ) == 0 and not turtle.compareDown() and not turtle.detectDown() then
turtle.select( 15 )
if turtle.placeDown() then
print( "[check]: Liquid detected!" )
if turtle.refuel() then
print( "[check]: Refueled using lava source!" )
turtle.down()
check( nLevel + 1 )
while not turtle.up() do end
ignoredFuel = ignoredFuel + 2
else
print( "[check]: Liquid was not lava!" )
turtle.placeDown()
end
end
end
--check for ore
if notwaste( turtle.compareDown ) then
print( "[check]: Ore Detected!" )
repeat turtle.digDown() until turtle.down()
print( "[check]: Dug ore!" )
check( nLevel + 1 )
while not turtle.up() do end
ignoredFuel = ignoredFuel + 2
end
end
Edit: Just realized, this literally takes no code whatsoever…
I'll just insert this in the proper places.
if turtle.detect() and turtle.suck() then
while turtle.suck() do end
end
Edited on 27 July 2014 - 01:33 PM
48 posts
Posted 03 August 2014 - 07:34 PM
An option I don't see, maybe it is in the code. I didn't look. An option to confine it to an area. x/y with optional z so you can confine it to an area where a chunk loader is. I tried one of these branch mining programs a long time ago and didn't put sand as waste because I wanted sand. But it found desert and the turtle had a chunk loader on board and was using an ender chest to unload ……… Took long time to find it in that mess. Maybe it could be a config menu option at start up.
Edited on 03 August 2014 - 05:35 PM
3057 posts
Location
United States of America
Posted 04 August 2014 - 12:42 AM
An option I don't see, maybe it is in the code. I didn't look. An option to confine it to an area. x/y with optional z so you can confine it to an area where a chunk loader is. I tried one of these branch mining programs a long time ago and didn't put sand as waste because I wanted sand. But it found desert and the turtle had a chunk loader on board and was using an ender chest to unload ……… Took long time to find it in that mess. Maybe it could be a config menu option at start up.
Well, I *could* add a distance, but it would mess up the way I use a time variable. I'd have to recode that part and possibly redo most of the script. I'll look into it though.
Edit: Also, why Z? This script will stick to the level you start it on, unless it finds something it wants to mine.
Edited on 03 August 2014 - 10:44 PM
48 posts
Posted 04 August 2014 - 02:42 AM
Why Z? Most mining scripts work their way down. Do the area at a level, move down, repeat. Doing by area would best be done in place of time. So if you do look into it, make it part of the option. Do by time or do by area.
3057 posts
Location
United States of America
Posted 04 August 2014 - 04:49 AM
Why Z? Most mining scripts work their way down. Do the area at a level, move down, repeat. Doing by area would best be done in place of time. So if you do look into it, make it part of the option. Do by time or do by area.
Ah, I think you are confused about the way this program works… It's
branch mining. Meaning it mines like this:
XXX XXX
XXX XXX
XXX XXX
XXX XXX
XXX XXX
XXX XXX
while scanning for ores/lava/inventories.
It will never venture up or down, unless it detects an 'ore', which it will mine and scan around.
48 posts
Posted 04 August 2014 - 06:59 PM
It can be vertical. There was one some time ago that did a center shaft vertical. It would dig a tunnel horizontal and then create branches every 3rd block coming back, then go down and do the same. I thought you did something like this:
-xxxxxxx
———-
-xxxxxxx
-xxxxxxx
-xxxxxxx
———
-xxxxxxx
Mine a horizontal tunnel every 4th block, skipping 3 blocks and repeat. Then drop one block and repeat the pattern under where you just where offset by 2 blocks. This exposes every block but greatly reduces the amount minded if there is nothing there. If you are mining a 3 high tunnel (up/forward/down), then drop down 2 instead of 1 to keep the offset right.
BTW, The strip miner program I'm using now and was trying to patch to check chest in the thread I started is:
http://www.computerc...hole-excavator/
Edited on 04 August 2014 - 05:03 PM
3057 posts
Location
United States of America
Posted 04 August 2014 - 08:57 PM
-snip-
Personally, I think the ratio of fuel-to-ore is best on a single layer, I could easily tell it to go up and down, but I think it would hurt fuel efficiency. If you want to mine multiple layers, just use multiple turtles. The only downside is, they will mine each other if they come into contact.
However, I may be creating a new turtle miner soon :)/>