Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mining Program with Nether Focus --
- -- Chest with Fuel above Turtle
- -- Dump Chest behind Turtle
- local numRODefault = 32
- local numRRDefault = 1
- -- Get Inputs --
- local inputs = {...}
- if tonumber(inputs[1]) > 0 then numRunsOut = inputs[1] else numRunsOut = numRODefault end
- if tonumber(inputs[2]) > 0 then numRunsRight = inputs[2] else numRunsRight = numRRDefault end
- -- ini User Varibles --
- local rSLowerLimit = 17
- local dropAmount = 15
- -- Turtle Slot Assignments --
- local fuelSlot = 1
- local rackSlot = 2
- local set = 2
- local inventoryCheck = 15
- -- ini Program Varibles --
- local tH = 0 -- Total Height,
- local sL = 1 -- Sleep Length in slp()
- local isHeadingOut = true
- local rAdj = 0 -- Total Right Adjust
- local oAdj = 0 -- Total Out Adjust
- local junk = "junk" -- Used in refuel pause
- local nR = 0 -- systems' track of runs Out
- local nRR = 0 -- systems' track of runs Right
- local refuelAmount = 1
- local fuelCheck = 10000
- --BASE FUNCTIONS--
- function slp() os.sleep(sL) end -- sleeps
- function tRound() turtle.turnLeft() turtle.turnLeft() end -- obvious
- function mF() if turtle.detect() then turtle.dig() end while not turtle.forward() do slp() turtle.dig() end end -- if movement fails, dig in that direction, wait a sec, then try again. repeat until success.
- function mB() while not turtle.back() do slp() tRound() turtle.dig() tRound() end end
- function mU() if turtle.detectUp() then turtle.digUp() end while not turtle.up() do slp() turtle.digUp() end end
- function mD() if turtle.detectDown() then turtle.digDown() end while not turtle.down() do slp() turtle.digDown() end end
- function tR() turtle.turnRight() end --shorthand
- function tL() turtle.turnLeft() end
- function rA()
- tR()
- for i = 1,rAdj do mF() end
- tL()
- end
- function oA()
- for i = 1,oAdj do mF() end
- end
- function dF()
- turtle.select(rackSlot)
- if turtle.detect() then
- if not turtle.compare() then
- turtle.dig() end end
- turtle.select(set)
- end
- function cF()
- dF() tR()
- dF() tL()
- end
- function rtS()
- for i = 1,tH do
- mU() end
- end
- function rtM()
- for i = 1,tH do
- mD() end
- end
- function preDump()
- if isHeadingOut then
- tRound()
- end
- oA()
- rA()
- end
- function dump()
- for i = 3,16 do
- turtle.select(i)
- turtle.drop() end
- turtle.select(rackSlot)
- while turtle.getItemCount() > rSLowerLimit do
- turtle.drop(dropAmount) end
- tRound()
- turtle.select(set)
- end
- function postDump()
- rA()
- oA()
- if not isHeadingOut then tRound() end
- end
- function rFuel()
- turtle.select(fuelSlot)
- while turtle.getFuelLevel() <= fuelCheck do
- shell.run("refuel","1")
- turtle.suckUp(1)
- end
- turtle.select(set)
- end
- function cI()
- if turtle.getItemCount(inventoryCheck) >= 1 then
- rtS()
- preDump()
- dump()
- rFuel()
- postDump()
- rtM() end
- end
- function digDn()
- if dD() then
- tH += 1
- else
- cFail()
- end
- end
- function dD()
- local k = 0
- turtle.digDown()
- for k = 1,5 do
- if turtle.down() then
- return true
- else
- turtle.digDown()
- sleep(.5)
- end
- end
- if k >= 4 then return false
- else print ("Error in bedrock detection. Failed to return true, Failed to try enough to return false. /n Stopping by endless while loop (Ctrl+t for 1 sec)") while true do sleep(30) end end
- end
- function cFail()
- rtS()
- for i = 1,2 do
- mF()
- if isHeadingOut then oAdj += 1
- else oAdj -= 1
- end
- write(tH.."|")
- tH = 0
- nR = nR + 1
- end
- end
- function runForward()
- postDump()
- for i=1,2 do
- while nR <= (numRunsOut-1) do
- cI()
- digDn()
- cF()
- end
- if isHeadingOut then
- mF()
- oAdj += 1
- tR()
- mF() mF()
- rAdj = rAdj + 2
- tR()
- isHeadingOut = false
- nR = 0
- end
- end
- preDump()
- dump()
- nRR = nRR + 1
- end
- --XX--PROGRAM--START--XX--
- --Refuel for complete run (once); May need tweaking; done in Program Varibles --
- rFuel()
- -- MAIN LOOP --
- while nRR <= numRunsRight do
- runForward()
- oAdj = 0
- nR = 0
- rAdj = nRR * 3
- isHeadingOut = true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement