Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- NOTES
- -- Will mine out at 22x3x2(lxwxh) tunnel, and then branch out of each side ~every 4 blocks
- -- does not currently account for a full inventory
- -- PLANS
- -- inventory sensitive
- -- cross hatched branches
- -- empty space sensitive
- -- light sensitive
- -- VARS
- -- Basic Functions
- function refuel( ammount )
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == "unlimited" then
- return true
- end
- local needed = ammount or (xPos + zPos + depth + 2)
- if turtle.getFuelLevel() < needed then
- local fueled = false
- for n=1,16 do
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- while turtle.getItemCount(n) > 0 and turtle.getFuelLevel() < needed do
- turtle.refuel(1)
- end
- if turtle.getFuelLevel() >= needed then
- turtle.select(1)
- return true
- end
- end
- end
- end
- turtle.select(1)
- return false
- end
- return true
- end
- function tryForward(tf)
- if not refuel() then
- print( "Not enough Fuel" )
- return false
- end
- if turtle.detect() then
- turtle.dig()
- end
- if tf then -- if move forward
- turtle.forward()
- end
- return true
- end
- function turnLeft()
- if not refuel() then
- print( "Not enough Fuel" )
- return false
- end
- turtle.turnLeft()
- return true
- end
- function turnRight()
- if not refuel() then
- print( "Not enough Fuel" )
- return false
- end
- turtle.turnRight()
- return true
- end
- function tryUp(tf)
- if not refuel() then
- print( "Not enough Fuel" )
- return false
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- if tf then -- if move up
- turtle.up()
- end
- return true
- end
- -- Advanced Functions
- function leftBranch()
- local banLen
- banLen = 4
- -- first branchB
- for l=1, banLen do -- go the length of var
- tryForward(true)
- tryUp(false)
- end
- turnRight()
- turnRight()
- for l=1, banLen do -- go back to start
- tryForward(true)
- end
- turnLeft()
- turnLeft()
- -- 2nd-6th branchB's
- for tun=1, 5 do -- 5 tunnels per side
- -- setup
- banLen=banLen+4
- turnRight()
- for l=1, 4 do
- tryForward(true)
- end
- turnLeft()
- -- mine
- for l=1, banLen do -- go the length of var
- tryForward(true)
- tryUp(false)
- end
- turnRight()
- turnRight()
- for l=1, banLen do -- go back to start
- tryForward(true)
- end
- turnLeft()
- turnLeft()
- end
- end
- function rightBranch()
- local banLen
- banLen = 4
- -- first branchB
- for l=1, banLen do -- go the length of var
- tryForward(true)
- tryUp(false)
- end
- turnLeft()
- turnLeft()
- for l=1, banLen do -- go back to start
- tryForward(true)
- end
- turnRight()
- turnRight()
- -- 2nd-6th branchB's
- for tun=1, 5 do -- 5 tunnels per side
- -- setup
- banLen=banLen+4
- turnLeft()
- for l=1, 4 do
- tryForward(true)
- end
- turnRight()
- -- mine
- for l=1, banLen do -- go the length of var
- tryForward(true)
- tryUp(false)
- end
- turnLeft()
- turnLeft()
- for l=1, banLen do -- go back to start
- tryForward(true)
- end
- turnRight()
- turnRight()
- end
- end
- function main() -- dig 20x3x2(lxwxh) tunnel
- local maLen = 22
- for l=1, maLen do -- go maLen blocks
- tryForward(true) -- dig first block in front
- tryUp(false)
- turnLeft()
- tryForward(true)
- turnRight()
- tryUp(false)
- turnRight()
- tryForward(true)
- tryForward(true)
- turnLeft()
- tryUp(false)
- turnLeft()
- tryForward(true)
- turnRight()
- end
- turnRight()
- turnRight()
- for l=1, maLen do -- go maLen blocks (back the way we came, so that we are at start)
- tryForward(true)
- end
- turnLeft()
- turnLeft() -- is now back at start
- -- first tunnel starts @ (currentL+2) and is 4 long, increment start by +4 and length by +4 per tunnel
- tryForward(true)
- tryForward(true) -- get to currentL+2
- turnLeft()
- tryForward(true)
- leftBranch()
- print("Left side Done")
- turnRight()
- turnRight()
- tryForward(true)
- turnRight()
- for l=1, maLen do
- tryForward(true)
- end
- turnLeft()
- turnLeft()
- tryForward(true)
- tryForward(true)
- turnRight()
- tryForward(true)
- rightBranch()
- print("Right side Done")
- turnLeft()
- turnLeft()
- tryForward(true)
- turnLeft()
- for l=1, maLen do
- tryForward(true)
- end
- turnRight()
- turnRight()
- end
- -- Main Program
- main()
- print("Branch Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement