Jump to content




King's Branch Mining Script


13 replies to this topic

#1 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 25 July 2014 - 03:37 PM

What it does
1. 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 up
5. 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 up
1. 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 Identified
1. 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.

Download
pastebin get ZpKSLTgW*

detecting liquids

*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 by KingofGamesYami, 27 July 2014 - 02:45 PM.


#2 bigbrainiac10

  • Members
  • 41 posts

Posted 25 July 2014 - 04:43 PM

Loving the fuel efficiency the most, and the keeping logs too!

View PostKingofGamesYami, on 25 July 2014 - 03:37 PM, said:

-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!

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 25 July 2014 - 04: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.

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 25 July 2014 - 08: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.

#5 hilburn

  • Members
  • 153 posts
  • LocationLondon, England

Posted 25 July 2014 - 09: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

#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 25 July 2014 - 09:15 PM

View Posthilburn, on 25 July 2014 - 09:08 PM, said:

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 by KingofGamesYami, 25 July 2014 - 09:31 PM.


#7 Mirodin

  • Members
  • 33 posts

Posted 27 July 2014 - 02: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

#8 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 27 July 2014 - 02:26 PM

View PostMirodin, on 27 July 2014 - 02:19 PM, said:

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
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 by KingofGamesYami, 27 July 2014 - 02:33 PM.


#9 Vorg

  • Members
  • 48 posts

Posted 03 August 2014 - 06: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 by Vorg, 03 August 2014 - 06:35 PM.


#10 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 03 August 2014 - 11:42 PM

View PostVorg, on 03 August 2014 - 06:34 PM, said:

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 by KingofGamesYami, 03 August 2014 - 11:44 PM.


#11 Vorg

  • Members
  • 48 posts

Posted 04 August 2014 - 01: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.

#12 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 04 August 2014 - 03:49 AM

View PostVorg, on 04 August 2014 - 01:42 AM, said:

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.

#13 Vorg

  • Members
  • 48 posts

Posted 04 August 2014 - 05: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 by Vorg, 04 August 2014 - 06:03 PM.


#14 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 04 August 2014 - 07:57 PM

View PostVorg, on 04 August 2014 - 05:59 PM, said:

-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 :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users