Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- mining <distancia>
- local arguments = {...}
- local current_fuel = turtle.getFuelLevel()
- local necessary_fuel = 4*arguments[1]
- local total_torches = 0
- local count_tourch = 0
- local put_tourch = 5
- -- Anti bug
- if #arguments ~= 1 then print("mining <distancia>") return end
- if tonumber(arguments[1]) < 1 then print("Digite um valor válido.") return end
- if current_fuel < necessary_fuel then
- turtle.refuel(necessary_fuel)
- if current_fuel < necessary_fuel then
- print("Preciso de "..(necessary_fuel-current_fuel).." combustíveis para iniciar.")
- return
- end
- end
- for i=1, 16 do
- turtle.select(i)
- local item = turtle.getItemDetail(i, true)
- if item ~= nil then
- if item.name == "minecraft:torch" then
- total_torches = total_torches + item.count
- end
- end
- end
- if tonumber(string.format("%.0f", tostring(arguments[1]/put_tourch))) > total_torches then
- print("Eu preciso de "..tonumber(string.format("%.0f", tostring(arguments[1]/put_tourch))) - total_torches.." tochas para começar.")
- return
- end
- print("Combustivel atual: "..turtle.getFuelLevel())
- print("Necessario: "..necessary_fuel)
- print("Iniciando...")
- -- Main loop
- for i=1, arguments[1] do
- if turtle.detect() then
- turtle.dig("right")
- end
- turtle.forward()
- if turtle.detectDown() then
- turtle.digDown("right")
- end
- turtle.down()
- if turtle.detectDown() then
- turtle.suckDown()
- else
- for i=1, 16 do
- turtle.select(i)
- local item = turtle.getItemDetail(i, true)
- if item ~= nil then
- if item.name == "minecraft:cobblestone" then
- turtle.placeDown()
- break
- end
- end
- end
- end
- turtle.up()
- if count_tourch == put_tourch then
- for i=1, 16 do
- turtle.select(i)
- local item = turtle.getItemDetail(i, true)
- if item ~= nil then
- if item.name == "minecraft:torch" then
- turtle.placeDown("minecraft:torch")
- count_tourch = 0
- break
- end
- end
- end
- end
- count_tourch = count_tourch + 1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, arguments[1] do
- turtle.forward()
- end
- print("Mineração concluida com sucesso.")
Advertisement
Add Comment
Please, Sign In to add comment