Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - --Foogles Mining Software
 - --Foogle Proof Mine 1.1 (7/30/2015)
 - --Install: in your turtle console, type pastebin get <code> Mine
 - -- the code will be in the forum contents
 - --Pre-Launch: put a bucket (empty or with lava) in any inventory slot
 - -- place 32 or more cobblestone in any inventory slot(s)
 - --Launch: type the file name (in this case Mine) followed by a number
 - -- for how long you want the mine shaft to be
 - -- because this turtle program doesn't support chest use, you
 - -- shouldn't make it longer than 100 to avoid overfilling your turtle
 - -- For example, type: Mine 30
 - -- To make the turtle mine a 30 block shaft and then come back
 - --global variables (their scope applies to all functions in this file)
 - args = {...}
 - local reg = 0
 - local up = 1
 - local down = 2
 - --this is the only function that is automatically called, and all
 - --it really does is coordinates the order that the methods
 - --which actually accomplish things will be executed in
 - --1. GetBuild() Find a block of cobblestone for building walls
 - --2. Continue() Move forward, clearing a 1x2 path (even if gravel is in the way)
 - --3. Search() Analyze the nearby blocks, searching for ores, gaps, lava, and water
 - -- This function will also call methods to obtain lava for automatic fueling
 - --4. CheckFuel() Attempt to refuel with a lava bucket if the fuel tank is less than 99% full
 - --5. Return() This function will utilize Continue() to return to the starting location
 - function Mine()
 - for i=1,args[1],1 do --do this the amount of times you specified (ex. Mine 10, does it 10 times)
 - CheckFuel()
 - GetBuild()
 - Continue()
 - Search()
 - end
 - Return()
 - end
 - --this function is used to find a building block (cobblestone)
 - --in the inventory and select it before placing a block
 - --it starts at the beginning and checks every inventory slot until
 - --it finds cobblestone, or reaches the end. If it finds cobble,
 - --it selects it
 - function GetBuild()
 - for i=1,16 do
 - if (turtle.getItemDetail(i) ~= nil) then
 - if (turtle.getItemDetail(i).name == 'minecraft:cobblestone' or turtle.getItemDetail(i).name == 'minecraft:dirt') then
 - turtle.select(i)
 - break
 - end
 - end
 - end
 - end
 - --this behaves similarly to GetBuild() but instead tries to find a lava
 - -- bucket which this turtle uses for fuel
 - function GetFuel()
 - for i=1,16 do
 - if (turtle.getItemDetail(i) ~= nil) then
 - if (turtle.getItemDetail(i).name == 'minecraft:lava_bucket') then
 - turtle.select(i)
 - break
 - end
 - end
 - end
 - end
 - --this behaves similarly to GetFuel() but it tries to find an
 - --empty bucket to refill
 - function GetBucket()
 - for i=1,16 do
 - if (turtle.getItemDetail(i) ~= nil) then
 - if (turtle.getItemDetail(i).name == 'minecraft:bucket') then
 - turtle.select(i)
 - return true
 - end
 - end
 - end
 - return false
 - end
 - --This search function makes the turtle move and turn towards
 - --all visible blocks in one vertical sliver of the mine shaft
 - function Search()
 - turtle.turnLeft() --face lower left block
 - Check(reg) --check block in front of it
 - turtle.up() --face upper left block
 - Check(reg)
 - turtle.turnRight()
 - turtle.turnRight() --face upper right block
 - Check(reg)
 - Check(up) --check block above it
 - if (turtle.down() == false) then --face lower right block
 - turtle.digDown()
 - turtle.down()
 - end
 - Check(reg)
 - Check(down) --check block below it
 - turtle.turnLeft() --face forward again
 - end
 - --This function analyzes a block in front, above, or below
 - --and determines what to do about it.
 - --1. If it detects air, it will place cobblestone
 - --2. If it detects a non dirt, cobblestone, gravel, or stone block,
 - -- it will mine it and place cobblestone
 - --3. If it detects lava, it will attempt to pick it up with a bucket
 - --4. It will move into a water/lava block above or beneath it to remove
 - -- the source and then fill it with cobblestone to seal the passage
 - function Check(dir)
 - local throw, success, block = 0;
 - if (dir == up) then
 - throw, block = turtle.inspectUp() --save what the block above it is
 - elseif (dir == down) then
 - throw, block = turtle.inspectDown() --save what the block below it is
 - else
 - throw, block = turtle.inspect() --save what the block in front of it is
 - end
 - success = 1
 - --if it finds lava, it will select an empty bucket and collect the lava
 - if (block.name == 'minecraft:lava' or block.name == 'minecraft:flowing_lava') then
 - GetBucket()
 - if (dir == up) then
 - turtle.placeUp()
 - elseif (dir == down) then
 - turtle.placeDown()
 - else
 - turtle.place()
 - end
 - GetBuild() --switches back to the building block (cobble)
 - end
 - --below, it scans a block in front, above, or beneath it
 - --and replaces if with cobblestone if it is not on the white list below
 - --if it runs out of cobblestone, it may place a random block
 - if (block.name ~= 'minecraft:stone' and block.name ~= 'minecraft:dirt' and block.name ~= 'minecraft:gravel' and block.name ~= 'minecraft:cobblestone') then
 - if (dir == up) then
 - turtle.digUp()
 - success = turtle.placeUp()
 - elseif (dir == down) then
 - turtle.digDown()
 - success = turtle.placeDown()
 - else
 - turtle.dig()
 - turtle.place()
 - end
 - --sometimes when it tries to place a block in a liquid space it fails
 - --to combat this, it will "fill" the space by moving into it and then out
 - --and placing cobblestone before the liquid flows back in
 - if (success == false) then
 - Fill(dir)
 - end
 - end
 - end
 - --this function is short but powerful. It is solely responsible
 - --for making sure that the turtle moves the correct number of spaces
 - --First it digs in front of it, then it moves into the space if possible
 - --Then it digs up. If it failed to move into the space,
 - --It will call itself again. This usually only happens with gravel
 - --or sand, but it also triggers when an entity blocks its path
 - --It doesn't have path finding for alternate routes, but it will keep
 - --trying to move and dig until the path is clear
 - function Continue()
 - turtle.dig()
 - local x = turtle.forward()
 - turtle.digUp()
 - if (x == false) then
 - Continue()
 - end
 - end
 - --This short function utilizes the recursion of continue() to (hopefully)
 - --guarantee that it will return to the place where it was left, including
 - --the same orientation. The turtle will not repair walls and seal the
 - --shaft on the way back, but instead it will quickly mine any
 - --gravel or obstacles that have fallen into the shaft on its
 - --return trip
 - function Return()
 - turtle.turnLeft()
 - turtle.turnLeft()
 - for i=1,args[1],1 do
 - Continue()
 - end
 - turtle.turnLeft()
 - turtle.turnLeft()
 - end
 - --This function is used to fill in liquids in the floor and ceiling that
 - --the turtle would otherwise fail to seal, so that a player
 - --can walk through the shaft without hazards
 - function Fill(d)
 - if (d == 1) then
 - turtle.up()
 - turtle.down()
 - turtle.placeUp()
 - elseif (d == 2) then
 - turtle.down()
 - turtle.up()
 - turtle.placeDown()
 - end
 - end
 - --This function will refuel the turtle with a lava bucket if it is below 99%
 - function CheckFuel()
 - if (turtle.getFuelLevel() < 99000) then
 - GetFuel()
 - turtle.refuel()
 - end
 - end
 - --this method call starts the program, and goes
 - --at the end so it can find all the methods
 - Mine()
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment