Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fais une mine optimisée à partir d'un tunnel principal. La turtle creuse x blocs en face d'elle avant de revenir sur ses pas et de faire pareil 3 blocs plus loin dans le tunnel
- local function printUsage()
- print( "Usage:" )
- print( "mining <distance per shafts>" )
- print( "Inventory:" )
- print( "It is not mandatory, but fuel goes into the slot 1 and torches to the slot 2 if you care to supply some for me.")
- end
- local function placeTorch(justChecking)
- if type(turtle.getItemDetail(2)) == "table" then
- if turtle.getItemDetail(2).name == "minecraft:torch" then
- if not justChecking then
- turtle.select(2)
- turtle.placeUp()
- turtle.select(blockSlot)
- end
- blockSlot = 3
- torches = true
- else
- torches = false
- blockSlot = 2
- end
- else
- torches = false
- blockSlot = 2
- end
- end
- local function refuel()
- shell.run("refuel", "all")
- if turtle.getFuelLevel() == 0 then
- return false
- end
- turtle.select(blockSlot)
- return true
- end
- local function blockLiquids()
- while turtle.up() == false do end
- _, block = turtle.inspectUp()
- detect = turtle.detectUp()
- if type(block) == "table" and detect == false then -- it has most likely detected a liquid
- turtle.placeUp()
- end
- turtle.turnLeft()
- _, block = turtle.inspect()
- detect = turtle.detect()
- if type(block) == "table" and detect == false then
- turtle.place()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- _, block = turtle.inspect()
- detect = turtle.detect()
- if type(block) == "table" and detect == false then
- turtle.place()
- end
- turtle.down()
- _, block = turtle.inspect()
- detect = turtle.detect()
- if type(block) == "table" and detect == false then
- turtle.place()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- _, block = turtle.inspect()
- detect = turtle.detect()
- if type(block) == "table" and detect == false then
- turtle.place()
- end
- turtle.turnRight()
- end
- function digforward()
- if turtle.getFuelLevel() > 0 then
- if turtle.detectDown() == false then turtle.placeDown() end
- _, block = turtle.inspectUp()
- detect = turtle.detectUp()
- if type(block) == "table" then
- if block.name == "minecraft:gravel" or block.name == "minecraft:sand" then
- while turtle.detectUp() do turtle.digUp() sleep(0.5) end
- elseif type(block) == "table" and detect == false then
- blockLiquids()
- else
- while turtle.detectUp() do turtle.digUp() end
- end
- end
- _, block = turtle.inspect()
- if type(block) == "table" then
- if block.name == "minecraft:gravel" or block.name == "minecraft:sand" then
- while turtle.detect() do turtle.dig() sleep(0.5) end
- else
- while turtle.detect() do turtle.dig() end
- end
- end
- local walked = turtle.forward()
- if not walked then
- print("ERROR : Unable to move forward")
- if turtle.detect() then
- print("Il y a un bloc")
- while not digforward() do
- sleep(0.5)
- end
- else
- print("ERROR : There must be a mob.")
- while true do
- turtle.attack()
- walked = turtle.forward()
- if walked == true then break end
- end
- print("SUCCESS : Mob gone")
- end
- end
- else
- print("Lacking energy. Attempting to refuel.")
- if refuel() == false then
- print("ERROR : No more fuel.")
- shell.exit()
- end
- return false
- end
- return true
- end
- local tArgs = { ... }
- if #tArgs == 0 then
- printUsage()
- return false
- end
- local goal = tonumber(tArgs[1])-1
- placeTorch(true) --if arg==true then it doesnt place a torch it just does some checking
- while true do
- chemin = 0
- while chemin <= goal do
- if digforward() then
- chemin = chemin+1
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- chemin = 0
- while chemin <= goal do
- while turtle.forward() == false do
- --
- end
- chemin = chemin+1
- if torches == true then
- if (chemin%5) == 0 then --every 5 blocks
- placeTorch()
- end
- end
- end
- turtle.turnLeft()
- for i=0,3 do
- local walked = turtle.forward()
- if not walked then print("ERROR : End of tunnel") return end
- end
- turtle.turnLeft()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement