Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Dirty Digger v0.72
- -- + dropping torches between tunnels
- -- Dirty Digger v0.71
- -- + added digging in main tunnel if there are blocks in the way of starting new tunnels
- -- Dirty Digger v0.7
- -- + debugged support for parallel tunnels
- -- Dirty Digger v0.6
- -- + added support for parallel tunnels
- -- Dirty Digger v0.5
- -- + added support for regular chests
- -- Dirty Digger v0.4
- -- + dig, digUp, digDown functions that detect additional blocks to mine before moving on
- -- Dirty Digger v0.3
- -- + Added wall check and replace to fill in holes in the tunnel as its being mined.
- -- + Adjusted checks at end of mining sequence so space check is before torch check to avoid conflicts with the two
- -- Dirty Digger v0.2
- -- + Auto return to starting position
- -- Dirty Digger v0.1
- -- + 3x3 tunnels
- -- + enderchest storage
- -- + auto torch (every 4 blocks)
- -- + auto refuel (when below 10 fuel level)
- -- Roadmap:
- -- + Detect missing walls and replace
- -- + Make sure enderchest and torches can't be placed in same block
- -- + Parallel tunnels (left or right)
- -- + Variable tunnel width
- -- + Varible torch spacing
- -- + Slots to define trash blocks
- local function distanceCheck()
- print("===========")
- print("Tunnel Length to mine? (1-100)")
- local tunnelLength = tonumber(read())
- if tunnelLength and tunnelLength > 0 and tunnelLength < 101 then
- print("===========")
- print("Tunnel Length: "..tunnelLength)
- return tunnelLength
- else
- print("===========")
- print("Please enter a number between 1 and 100.")
- return distanceCheck()
- end
- end
- local function fuelCheck()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel < 10 then
- turtle.select(2)
- turtle.refuel(10)
- fuelLevel = turtle.getFuelLevel() -- Update fuel level after refueling
- print("===========")
- print("Fuel Level: "..fuelLevel)
- print("Low Fuel - Refueling!")
- else
- print("===========")
- print("Fuel Level: "..fuelLevel)
- print("Mining Turtle has sufficient fuel!")
- end
- return fuelLevel
- end
- local function torchCheck(distanceMoved)
- if distanceMoved % 4 == 0 then
- turtle.select(1)
- turtle.placeDown()
- end
- end
- local function enderDrop()
- turtle.select(16)
- turtle.placeDown()
- for i = 4, 15 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(16)
- turtle.digDown()
- turtle.digDown()
- end
- local function chestDrop()
- turtle.select(16)
- turtle.placeDown()
- for i = 4, 15 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- local function spaceCheck(chestType)
- local occupiedSlots = 0
- for i = 3, 15 do
- if turtle.getItemCount(i) > 0 then
- occupiedSlots = occupiedSlots + 1
- end
- end
- if occupiedSlots >= 13 then
- print("===========")
- print("Inventory full, time to unload!")
- if chestType == 1 then
- enderDrop()
- else
- chestDrop()
- end
- else
- print("===========")
- print("Still have space to continue mining.")
- end
- end
- local function wallCheck()
- local function replaceDown()
- if not turtle.detectDown() then
- turtle.placeDown()
- end
- end
- local function replaceForward()
- if not turtle.detect() then
- turtle.place()
- end
- end
- local function replaceUp()
- if not turtle.detectUp() then
- turtle.placeUp()
- end
- end
- turtle.select(3)
- turtle.down()
- replaceDown()
- turtle.turnLeft()
- turtle.forward()
- replaceDown()
- replaceForward()
- turtle.up()
- replaceForward()
- turtle.up()
- replaceForward()
- replaceUp()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- replaceUp()
- turtle.forward()
- replaceUp()
- replaceForward()
- turtle.down()
- replaceForward()
- turtle.down()
- replaceForward()
- replaceDown()
- turtle.back()
- turtle.up()
- turtle.turnLeft()
- end
- local function mine(distanceMoved, tunnelLength, chestType)
- local function dig()
- while turtle.detect() do
- turtle.dig()
- end
- end
- local function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- local function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- turtle.up()
- while tunnelLength >= 1 do
- dig()
- turtle.forward()
- distanceMoved = distanceMoved + 1
- tunnelLength = tunnelLength - 1
- digUp()
- digDown()
- turtle.turnLeft()
- dig()
- turtle.forward()
- digUp()
- digDown()
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- dig()
- turtle.forward()
- digUp()
- digDown()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- fuelCheck()
- wallCheck()
- spaceCheck(chestType)
- torchCheck(distanceMoved)
- end
- turtle.down()
- return distanceMoved
- end
- local function readyCheck()
- print("===========")
- print("When materials are in slots, press Y to start mining.")
- local input = read():upper()
- if input == "Y" then
- print("===========")
- print("Starting to mine!")
- return true
- else
- print("===========")
- print("Please type 'Y' when ready.")
- return readyCheck()
- end
- end
- local function chestCheck()
- print("===========")
- print("Are you using an EnderChest? (Y/N)")
- local input = read():upper()
- if input == "Y" or input == "y" then
- return 1
- else
- return 2
- end
- end
- local function tunnelCheck()
- print("===========")
- print("How many parallel tunnels would you like to mine? (1-100)")
- local tunnelCount = tonumber(read())
- if tunnelCount and tunnelCount > 0 and tunnelCount < 101 then
- print("===========")
- print("Tunnel Count: "..tunnelCount)
- return tunnelCount
- else
- print("===========")
- print("Please enter a number between 1 and 100.")
- return tunnelCheck()
- end
- end
- local function main()
- term.clear()
- print("===========")
- print("Dirty Digger v0.71")
- print("Created by Stormy Waters")
- -- instruction where to put materials
- print("===========")
- print("Place these materials in the following slots:")
- print("Slot 1: Torches")
- print("Slot 2: Fuel")
- print("Slot 3: Cobblestone")
- print("Slot 16: Storage Chest")
- local tunnelLength = distanceCheck()
- local chestType = chestCheck()
- local tunnelCount = tunnelCheck()
- -- added local functions for dig and dig up that include detection
- local function dig()
- while turtle.detect() do
- turtle.dig()
- end
- end
- local function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- local function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- fuelCheck()
- if readyCheck() then
- for i = 1, tunnelCount do
- local distanceMoved = mine(0, tunnelLength, chestType)
- turtle.turnLeft()
- turtle.turnLeft()
- for j = 1, distanceMoved do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- -- added dig():330 and digUp():332
- if i < tunnelCount then
- turtle.turnRight()
- for k = 1, 2 do
- dig()
- turtle.forward()
- digUp()
- turtle.up()
- digUp()
- dig()
- turtle.forward()
- digUp()
- digDown()
- turtle.down()
- end
- -- insert torch on ground below
- turtle.select(1)
- turtle.placeUp()
- turtle.turnLeft()
- end
- end
- print("||======================||")
- print("|| Mining 100% Complete ||")
- print("||======================||")
- else
- print("Exiting program.")
- end
- end
- main()
Add Comment
Please, Sign In to add comment