Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----Quick Configs-------------
- nonOre = {"gross:stuff"}
- ignore = { "minecraft:stone",
- "minecraft:sand",
- "minecraft:gravel",
- "minecraft:dirt",
- "chisel:chisel.limestone",
- "chisel:chisel.marble" }
- -------------------------------
- check = {}
- shaftVal = 0
- function fuelCheck()
- if turtle.getFuelLevel() < 80 then
- local tmp = turtle.getSelectedSlot()
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(tmp)
- end
- end
- function genericInspect(check,arg)
- for i = 1,#ignore do
- if check.name == ignore[i] then
- return false
- end
- end
- for i = 1,#arg do
- if check.name == arg[i] then
- return false
- end
- end
- return true
- end
- function identify(arg)
- local dig
- local tmp
- local tmp2
- turtle.turnLeft()
- tmp,tmp2 = turtle.inspect()
- dig = genericInspect(tmp2,arg)
- if dig then
- turtle.dig()
- end
- turtle.turnRight()
- turtle.turnRight()
- tmp,tmp2 = turtle.inspect()
- dig = genericInspect(tmp2,arg)
- if dig then
- turtle.dig()
- end
- turtle.turnLeft()
- tmp,tmp2 = turtle.inspectDown()
- dig = genericInspect(tmp2,arg)
- if dig then
- turtle.digDown()
- end
- turtle.up()
- tmp,tmp2 = turtle.inspectUp()
- dig = genericInspect(tmp2,arg)
- if dig then
- turtle.digUp()
- end
- turtle.turnRight()
- tmp,tmp2 = turtle.inspect()
- dig = genericInspect(tmp2,arg)
- if dig then turtle.dig() end
- turtle.turnLeft()
- turtle.turnLeft()
- tmp,tmp2 = turtle.inspect()
- dig = genericInspect(tmp2,arg)
- if dig then turtle.dig() end
- turtle.turnRight()
- turtle.down()
- end
- function nextStep()
- fuelCheck()
- while turtle.detect() do
- turtle.dig()
- sleep(.7)
- end
- turtle.forward()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(.7)
- end
- end
- function placeTorch()
- local tmp = turtle.getSelectedSlot()
- turtle.select(15)
- fuelCheck()
- turtle.up()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(.7)
- end
- turtle.placeUp()
- turtle.down()
- turtle.select(tmp)
- end
- function digBranch(depth,arg)
- for i = 1,depth do
- nextStep()
- identify(arg)
- if i == 1 or i%7 == 0 or i == depth then
- placeTorch()
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1,depth do
- turtle.forward()
- end
- end
- function nextTine(td,dir,arg)
- nextStep()
- if dir == "r" then identify(arg) end--
- nextStep()
- if dir == "r" then identify(arg) end--
- nextStep()
- if dir == "r" then identify(arg) end--
- if dir == "r" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- digBranch(td,arg)
- if dir == "r" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- function completeSide(tn,td,dir,arg)
- for i = 1, tn do
- nextTine(td,dir,arg)
- end
- turtle.turnRight()
- turtle.turnRight()
- for i = 1,tn*3 do
- fuelCheck()
- turtle.forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- function clearInv()
- turtle.turnRight()
- for i = 1,14 do
- turtle.select(i)
- if turtle.compareDown() then
- turtle.drop()
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1,14 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnRight()
- end
- function shaft(depth)
- shaftVal = depth
- local t = true
- fuelCheck()
- turtle.forward()
- for i = 1,depth do
- if i%40 == 0 then
- fuelCheck()
- end
- turtle.digDown()
- if not turtle.down() then
- shaftVal = i - 1
- end
- end
- for k = 1,depth do
- fuelCheck()
- if k%40 == 0 then
- fuelCheck()
- end
- turtle.up()
- end
- turtle.back()
- end
- function shaftDown(depth)
- fuelCheck()
- turtle.forward()
- for i = 1,depth do
- if i%40 == 0 then
- fuelCheck()
- end
- turtle.down()
- end
- end
- function shaftUp(depth)
- fuelCheck()
- for i = 1,depth do
- if i%40 == 0 then
- fuelCheck()
- end
- turtle.up()
- end
- turtle.back()
- end
- function fullMine(sd,tn,td,arg)
- shaft(sd)
- clearInv()
- shaftDown(sd)
- completeSide(tn,td,"r",arg)
- shaftUp(sd)
- clearInv()
- shaftDown(sd)
- completeSide(tn,td,"l",arg)
- shaftUp(sd)
- clearInv()
- end
- function fuelEstimate(sd,tn,td)
- return (((sd*4)+4)+(tn*18)+(((td*3)+td)*tn))
- end
- function torchEstimate(tn,td)
- return (tn+(td%7))
- end
- function invInsure()
- local tmp = {}
- tmp = turtle.getItemDetail(turtle.select(16))
- if tmp == nil then
- error("You must put coal in slot 16")
- end
- if tmp.name ~= "minecraft:coal" then
- error("You must put coal in slot 16")
- end
- tmp = turtle.getItemDetail(turtle.select(15))
- if tmp == nil then
- error("You must put torches or glowstone in slot 15")
- end
- if tmp.name ~= "minecraft:torch" and tmp.name ~= "minecraft:glowstone" then
- error("You must put torches or glowstone in slot 15")
- end
- end
- -----------
- --Program--
- -----------
- tArgs = {...}
- term.clear()
- term.setCursorPos(1,1)
- print("Shaft Depth: "..tostring(tArgs[1]))
- print("Number of Tines: "..tostring(tArgs[2]))
- print("Tine Depth: "..tostring(tArgs[3]))
- write("Total Blocks of Travel: ")
- local tfuel = fuelEstimate(tArgs[1],tArgs[2],tArgs[3])
- local ttorch = torchEstimate(tArgs[2],tArgs[3])
- print(tfuel)
- write("Total Mandatory Fuel: ")
- print(tfuel/80)
- write("Total Mandatory Torches: ")
- print(ttorch)
- invInsure()
- if tfuel/80 > 64 or tfuel/80 > turtle.getItemCount(turtle.select(16)) then
- --error("Not enough fuel!")
- printError("Not enough fuel!")
- local count = 0
- local x,y = term.getCursorPos()
- print("Add "..tostring((tfuel/80)-turtle.getItemCount(turtle.select(16))).." more fuel to continue!")
- while tfuel/80 > turtle.getItemCount(turtle.select(16)) do
- term.setCursorPos(x,y)
- print("Add "..tostring((tfuel/80)-turtle.getItemCount(turtle.select(16))).." more fuel to continue!")
- count = count + 1
- sleep(3)
- if count == 60 then error("Timeout error on refuel") end
- end
- end
- if ttorch > 64 or ttorch > turtle.getItemCount(turtle.select(15)) then
- printError("Not enough torches!")
- local x,y = term.getCursorPos()
- print("Add "..tostring(ttorch - turtle.getItemCount(turtle.select(15))).." more to continue!")
- local count = 0
- while ttorch > turtle.getItemCount(turtle.select(15)) do
- term.setCursorPos(x,y)
- print("Add "..tostring(ttorch - turtle.getItemCount(turtle.select(15))))
- count = count + 1
- sleep(3)
- if count == 60 then error("Timeout error on torch fill") end
- end
- end
- print("Proceeding with dig...")
- fullMine(tArgs[1],tArgs[2],tArgs[3],tArgs)
- print("Dig complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement