Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function mine(x)
- local counter = 0
- repeat
- turtle.dig()
- moveForward(1)
- turtle.digUp()
- counter = counter + 1
- until counter == x
- end
- local function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end
- function moveForward(x)
- for i = 1, x, 1 do
- if turtle.forward() then
- -- nichts passiert
- else
- if turtle.detect() then
- while(turtle.detect()) do
- turtle.dig()
- end
- moveForward(1)
- else
- os.shutdown()
- end
- end
- end
- end
- local function placeTorch()
- turtle.up()
- turtle.select(2)
- turtle.back()
- turtle.place()
- turtle.down()
- end
- local function stripMine(x, placeTorches)
- for i = 1, x, 1 do
- mine(3)
- if i % 2 == 1 and placeTorches then
- turtle.back()
- placeTorch()
- moveForward(2)
- end
- turtle.turnRight()
- mine(8)
- if placeTorches then
- placeTorch()
- else
- turtle.back()
- end
- turnAround()
- moveForward(7)
- mine(8)
- if placeTorches then
- placeTorch()
- else
- turtle.back()
- end
- turnAround()
- moveForward(7)
- turtle.turnLeft()
- for j=1, 16, 1 do
- local slot = turtle.getItemDetail(j)
- if slot ~= nil then
- if slot["name"] == "minecraft:cobblestone" then
- turtle.select(j)
- turtle.drop()
- end
- end
- end
- end
- end
- local function calculateFuel(numberOfCorridors)
- return (numberOfCorridors * 40) + (6 * math.ceil(numberOfCorridors / 2))
- end
- local function calculateTorches(numberOfCorridors)
- local additionalTorches = math.ceil(numberOfCorridors / 2)
- return (numberOfCorridors * 2) + additionalTorches
- end
- local function printWithConfirmation(string)
- print(string)
- local input = read()
- if input ~= "y" and input ~= "yes" then
- os.shutdown()
- end
- end
- print("Ultimate Miner by KingKevin23")
- print("How many corridors should be mined?")
- local numberOfCorridors = tonumber(read())
- print("Should I place torches? (y/n)")
- local placeTorches = read() == "y"
- local fuelNeeded = calculateFuel(numberOfCorridors) - turtle.getFuelLevel()
- if fuelNeeded > 0 then
- printWithConfirmation("Please provide " .. math.ceil(fuelNeeded / 80) .. " coal items in slot 1. \n Alternatively you can manually fuel with " .. math.ceil(fuelNeeded / 1000) .. " lava!")
- end
- if placeTorches then
- printWithConfirmation("Please provide " .. calculateTorches(numberOfCorridors) .. " torches in slot 2.")
- end
- turtle.select(1)
- turtle.refuel()
- stripMine(numberOfCorridors, placeTorches)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement