Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print("Usage: Hoehe <high>")
- return
- end
- -- Mine in a quarry pattern until we hit something we can`t dig
- local high = tonumber( tArgs[1] )
- if high < 1 then
- print("Treppen hoehe must be positive")
- return
- end
- local depth = high
- local collected = 0
- local ll = 0
- print("Treppen in Fach 15 legen")
- print("Fackeln in Fach 14 legen")
- print("Steine in Fach 1 legen")
- print("Schritte bis Ebene 12 = ",high)
- print()
- print(" In 10 Sec geht es los")
- sleep(10)
- local function collect()
- collected = collected +1
- if math.fmod(collected, 25) == 0 then
- print("Mined "..collected.." items.")
- end
- end
- local function tryDig()
- while turtle.detect() do
- if turtle.dig() then
- collect()
- sleep(0.5)
- else
- return false
- end
- end
- return true
- end
- local function tryDigDown()
- while turtle.detectDown() do
- if turtle.digDown() then
- collect()
- sleep(0.5)
- else
- return false
- end
- end
- return true
- end
- local function tryDigUp()
- while turtle.detectUp() do
- if turtle.digUp() then
- collect()
- sleep(0.5)
- else
- return false
- end
- end
- return true
- end
- local function refuel()
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel == "unlimited" or fuelLevel > 0 then
- return
- end
- local function tryRefuel()
- for n=1,16 do
- if turtle.getItemCount(n) > 0 then
- turtle.select(n)
- if turtle.refuel(1) then
- turtle.select(1)
- return true
- end
- end
- end
- turtle.select(1)
- return false
- end
- if not tryRefuel() then
- print( "Add more fuel to continue." )
- while not tryRefuel() do
- sleep(1)
- end
- print( "Resuming Tunnel." )
- end
- end
- local function tryUp()
- refuel()
- while not turtle.up() do
- if turtle.detectUp() then
- if not tryDigUp() then
- return false
- end
- elseif turtle.attackUp() then
- collect()
- else
- sleep( 0.5 )
- end
- end
- return true
- end
- local function tryDown()
- refuel()
- while not turtle.down() do
- if turtle.detectDown() then
- if not tryDigDown() then
- return false
- end
- elseif turtle.attackDown() then
- collect()
- else
- sleep( 0.5 )
- end
- end
- return true
- end
- local function tryForward()
- refuel()
- while not turtle.forward() do
- if turtle.detect() then
- if not tryDig() then
- return false
- end
- elseif turtle.attack() then
- collect()
- else
- sleep( 0.5 )
- end
- end
- return true
- end
- print( "Baue die Treppe...")
- tryDig()
- tryForward()
- ll=0
- for n=1,high do
- tryForward()
- tryUp()
- tryUp()
- tryUp()
- tryDown()
- tryDown()
- ll = ll +1
- if ll == 5 then
- turtle.turnRight()
- tryDig()
- turtle.select(14)
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- tryDig()
- turtle.place()
- turtle.turnRight()
- ll = 0
- end
- end
- if n<high then
- tryDig()
- if not tryForward() then
- print( "Aborting Tunnel." )
- end
- else
- print( "Tunnel complete." )
- end
- print( "Mined "..collected.." items total." )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement