Branch Mining Script

Started by KingofGamesYami, Aug 13, 2018, 02:23 am

Previous topic - Next topic

KingofGamesYami

Reposted from here

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*

I thought I might as well throw in the way I detect liquids.
Code Select
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.
I'm a ComputerCraft veteran with over 3k posts on the old ComputerCraft Forum.  I'm mostly inactive in CC having moved on to bigger, more interesting projects but still contribute to the community.