Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local defaultDistanceTorch = 0
- local defaultDistanceBuild = 0
- local distanceBuild = 0
- local distanceTorch = 0
- local itemsNeeded = 3
- local incorrectItems = 3
- local checkFuel, checkChest, checkTorch, getInventory, checkInventory, dig
- local fuelData = turtle.getItemDetail(1)
- local chestData = turtle.getItemDetail(2)
- local torchData = turtle.getItemDetail(3)
- local fullData = turtle.getItemDetail(16)
- local fuel = 0
- local chest = 0
- local torch = 0
- local function restart()
- local itemsNeeded = 3
- local incorrectItems = 3
- term.clear()
- getInventory()
- checkInventory()
- end
- local function start()
- term.clear()
- print("Turtle is ready to start!")
- write("Distance: ")
- local distanceInput = read()
- distanceInput = tonumber(distanceInput)
- if type(distanceInput) == "number" then
- defaultDistanceBuild = distanceInput
- distanceBuild = distanceInput
- term.clear()
- print("Turtle is ready to start!")
- write("Torch: ")
- local torchInput = read()
- torchInput = tonumber(torchInput)
- if type(torchInput) == "number" then
- defaultDistanceTorch = torchInput
- distanceTorch = torchInput
- dig()
- else
- print("Please insert a number!")
- sleep(0.5)
- term.clear()
- start()
- end
- else
- print("Please insert a number!")
- sleep(0.5)
- term.clear()
- start()
- end
- end
- local function work()
- print("Mining... Distance: " .. distanceBuild .. "/" .. defaultDistanceBuild .. " Torches: " .. distanceTorch .. "/" .. defaultDistanceTorch)
- if turtle.detect() then
- turtle.dig()
- turtle.forward()
- distanceBuild = distanceBuild - 1
- distanceTorch = distanceTorch - 1
- else
- turtle.forward()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- dig()
- end
- getInventory = function()
- fuel = turtle.getItemCount(1)
- chest = turtle.getItemCount(2)
- torch = turtle.getItemCount(3)
- end
- checkInventory = function()
- term.clear()
- print("Checking Fuel...")
- if fuel == 0 then
- print("Missing: Fuel - Slot 1")
- else
- print("Enough Fuel")
- itemsNeeded = itemsNeeded - 1
- end
- print(" ")
- print("Checking Chests...")
- if chest == 0 then
- print("Missing: Chest - Slot 2")
- else
- print("Enough Chests")
- itemsNeeded = itemsNeeded - 1
- end
- print(" ")
- print("Checking Torch...")
- if torch == 0 then
- print("Missing: Torch - Slot 3")
- else
- print("Enough Torch")
- itemsNeeded = itemsNeeded - 1
- end
- if itemsNeeded == 0 then
- print(" ")
- print("No more items needed!")
- sleep(1.5)
- checkFuel()
- else
- print(" ")
- print("Not enough items!")
- end
- end
- checkFuel = function()
- term.clear()
- print("Checking Fuel Data...")
- if fuelData then
- if fuelData.name == "minecraft:coal" then
- print("Correct Fuel Data: " .. fuelData.name)
- incorrectItems = incorrectItems - 1
- sleep(0.5)
- checkChest()
- local fullCheck = 1
- else
- print("Incorrect Fuel Data: " .. fuelData.name)
- end
- end
- end
- checkChest = function()
- term.clear()
- print("Checking Chest Data...")
- if chestData then
- if chestData.name == "minecraft:chest" then
- print("Correct Chest Data: " .. chestData.name)
- incorrectItems = incorrectItems - 1
- sleep(0.5)
- checkTorch()
- else
- print("Incorrect Chest Data: " .. chestData.name)
- end
- end
- end
- checkTorch = function()
- term.clear()
- print("Checking Torch Data...")
- if torchData then
- if torchData.name == "minecraft:torch" then
- print("Correct Torch Data: " .. torchData.name)
- incorrectItems = incorrectItems - 1
- sleep(0.5)
- start()
- else
- print("Incorrect Torch Data: " .. torchData.name)
- end
- end
- end
- local function turnTurtle()
- turtle.turnRight()
- turtle.turnRight()
- end
- local function placeChest()
- print("Placing chest...")
- if chestData then
- if chestData.name == "minecraft:chest" then
- print("Available Chests: " .. chestData.count)
- turtle.digDown()
- turtle.select(2)
- turtle.placeDown()
- print("Placed Chest!")
- for chestSlot = 4, 16 do
- turtle.select(chestSlot)
- turtle.dropDown()
- end
- else
- print("Incorrect Chest Data: " .. chestData.name .. " " .. chestData.count)
- end
- else
- print("Not enough chests!")
- end
- end
- local function placeTorch()
- print("Placing Torch...")
- if torchData then
- if torchData.name == "minecraft:torch" then
- print("Available Torches: " .. torchData.count)
- turnTurtle()
- turtle.select(3)
- turtle.place()
- print("Placed Torch!")
- turnTurtle()
- else
- print("Incorrect Torch Data: " .. torchData.name .. " " .. torchData.count)
- end
- else
- print("Not enough Torches!")
- end
- end
- local function refuel()
- print("Refueling...")
- if fuelData then
- if fuelData.name == "minecraft:coal" then
- print("Available Fuel: " .. fuelData.count)
- turtle.select(1)
- turtle.refuel(1)
- else
- print("Incorrect Fuel Data: " .. fuelData.name .. " " .. fuelData.count)
- end
- else
- print("Not enough Fuel!")
- end
- end
- dig = function()
- term.clear()
- if turtle.getFuelLevel() == 0 then
- refuel()
- end
- if fullData then
- placeChest()
- end
- if distanceTorch == 0 then
- placeTorch()
- distanceTorch = defaultDistanceTorch
- end
- if distanceBuild == 0 then
- placeChest()
- placeTorch()
- term.clear()
- print("Done!")
- else
- work()
- end
- end
- restart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement