Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- uses Robust Turtle API: pastebin get 0TnEBf2P t
- os.loadAPI("t")
- local args = {...}
- local versionNumber = "2.1"
- local programName = "StarDustMiner"
- local programNameShort = "SDMiner"
- local startInventory = 2
- local torchEnabled = true
- local torchName = "minecraft:torch"
- if #args ~= 2 then
- print ("Usage: "..programNameShort.." (Main Tunnel Length) (Individual Tunnel Length)")
- return
- else
- mainTL = tonumber(args[1])
- indivTL = tonumber(args[2])
- if mainTL < 1 then
- print("Main Tunnel Length must be positive")
- return
- end
- if indivTL < 1 then
- print("Individual Tunnel Length must be positive")
- return
- end
- -- INITIAL SETUP FASE
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome to"..programName.."Version "..versionNumber.." !")
- print("(Coded by MrHG using RobustTurtleAPI)")
- print("")
- sleep(1)
- -- FUEL CALCULATION
- -- for every 2 blocks after block 1 in MainTL, add 4 times IndivTL.
- -- then add 1 for every time you add 4xIndivTL. Then add another MainTL
- -- then add 80 just in case.
- local blocksToTravel = (2*mainTL) + (((math.floor(mainTL/2)+1)*4) * indivTL + 1) + 80
- if blocksToTravel>3000 then
- print("This will result in a mine bigger than 3000 blocks. Are you sure? (y/n)")
- if read()~="y" then
- print("Aborting operation")
- return
- end
- end
- print("Operation will need " .. blocksToTravel .. " fuel.")
- print("~" .. math.floor(blocksToTravel/80) .. " Pieces of coal.")
- print("Please ensure these are located in the top left slot.")
- print("To enable Torchmode, put torches next to the fuel.")
- print("Starting in 3 Seconds...")
- sleep(3)
- term.clear()
- print("Commencing Dig.")
- end
- function DisableTorchMode()
- print("No torches found, Disabling Torch Mode.")
- startInventory = 2
- torchEnabled = false
- return false
- end
- function checkForTorches()
- if torchEnabled == true then
- if turtle.getItemDetail(2) then
- if turtle.getItemDetail(2).name == torchName then
- startInventory = 3
- torchEnabled = true
- return true
- else
- DisableTorchMode()
- end
- else
- DisableTorchMode()
- end
- else
- startInventory = 2
- end
- end
- function Refuel(amountOfRequiredFuel)
- turtle.select(1)
- if (turtle.getFuelLevel() == "unlimited") then
- -- that's pretty neat dude.
- return
- end
- if (turtle.getFuelLevel() < amountOfRequiredFuel) then
- while (true) do
- if turtle.refuel(1) then
- if (turtle.getFuelLevel() > amountOfRequiredFuel) then
- break
- end
- else
- print("Turtle could not refuel. Please check why.")
- error()
- end
- end
- end
- end
- function PlaceTorch()
- if checkForTorches() then
- t.back()
- t.digUp()
- t.up()
- t.dig()
- t.place(2)
- t.down()
- t.forward()
- end
- end
- function DigIndivTunnel()
- for i=1,indivTL do
- Refuel(160)
- t.dig()
- t.forward()
- t.digUp()
- if indivTL % 7 ~= 0 and i % 7 == 0 and torchEnabled then
- t.up()
- t.right()
- t.forward()
- t.dig()
- t.back()
- t.place(2)
- t.left()
- t.down()
- end
- end
- if (torchEnabled) then
- PlaceTorch()
- end
- t.turnAround()
- Refuel(indivTL)
- t.forward(indivTL)
- end
- function EmptyInventory()
- local itemsDepositedCount = 0
- for i=startInventory,16 do
- turtle.select(i)
- itemsDepositedCount = itemsDepositedCount + turtle.getItemCount()
- if turtle.getItemCount() == 0 then
- --twiddle your thumbs
- elseif not turtle.drop() then
- print("Container full. Please empty it.")
- error()
- end
- end
- print("Deposited "..itemsDepositedCount.." Items.")
- if not torchEnabled then
- print("Torch mode currently Disabled.")
- print("Insert torches in slot 2 to enable.")
- sleep(3)
- torchEnabled = true
- if checkForTorches() then
- print("Torch mode Enabled.")
- end
- end
- turtle.select(1)
- end
- -- Main Block
- checkForTorches()
- t.turnAround()
- EmptyInventory()
- print("Inventory emptied. Heading out.")
- t.turnAround()
- local blocksAwayFromContainer = 0
- for i=1,mainTL do
- Refuel(160)
- t.dig()
- t.forward()
- blocksAwayFromContainer = blocksAwayFromContainer + 1
- t.digUp()
- if not (i%2 == 0) then
- t.left()
- DigIndivTunnel()
- -- Inventory check
- turtle.select(14)
- if turtle.getItemCount() > 0 then
- t.right()
- t.forward(blocksAwayFromContainer)
- EmptyInventory()
- t.turnAround()
- t.forward(blocksAwayFromContainer)
- t.right()
- end
- DigIndivTunnel()
- turtle.select(14)
- if turtle.getItemCount() > 0 then
- t.left()
- t.forward(blocksAwayFromContainer)
- EmptyInventory()
- t.turnAround()
- t.forward(blocksAwayFromContainer)
- else
- t.right()
- end
- else
- Refuel(160)
- t.right()
- t.dig()
- t.up()
- t.dig()
- if (torchEnabled) then
- if checkForTorches() then
- t.place(2)
- end
- end
- t.turnAround()
- t.dig()
- t.down()
- t.dig()
- t.right()
- end
- end
- t.turnAround()
- t.forward(mainTL)
- EmptyInventory()
- t.turnAround()
- print("")
- print("Dig Complete!")
- print("Thank you for using "..programName.."!")
- print("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement