Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local encontrados = 0
- local counter = 0
- local passos = 0
- local estado = "Esperando"
- function printCor(texto, cor) -- Imprime o texto com a cor desejada, depois volta pra branco.
- term.setTextColor(cor)
- print(texto)
- term.setTextColor(colors.white)
- end
- function atualizarMonitor()
- term.clear()
- term.setCursorPos(1,1)
- printCor("=============================", colors.yellow)
- printCor("I N F O R M A C O E S", colors.orange)
- imprimirInformacao()
- printCor("=============================", colors.yellow)
- end
- function imprimirInformacao()
- if(turtle.getFuelLevel() > 0) then
- print("Combustivel: "..turtle.getFuelLevel())
- else
- term.setTextColor(colors.red)
- print("Combustivel: "..turtle.getFuelLevel())
- term.setTextColor(colors.white)
- end
- print("Minerios encontrados: "..encontrados)
- print("Passos atรฉ dropar: "..20-counter)
- print("Passos andados: "..passos.."/858")
- print("")
- printCor(estado, colors.lightBlue)
- end
- function droparPedra()
- for i=1, 16 do
- turtle.select(i)
- if(turtle.getItemDetail()) then
- if turtle.getItemDetail().name == "minecraft:cobblestone" then
- turtle.drop()
- elseif turtle.getItemDetail().name == "minecraft:stone" then
- turtle.drop()
- elseif turtle.getItemDetail().name == "minecraft:dirt" then
- turtle.drop()
- elseif turtle.getItemDetail().name == "minecraft:gravel" then
- turtle.drop()
- elseif turtle.getItemDetail().name == "minecraft:cobbled_deepslate" then
- turtle.drop()
- elseif turtle.getItemDetail().name == "minecraft:diorite" then
- turtle.drop()
- elseif turtle.getItemDetail().name == "minecraft:andesite" then
- turtle.drop()
- elseif turtle.getItemDetail().name == "minecraft:tuff" then
- turtle.drop()
- end
- end
- end
- turtle.select(1)
- end
- function andar()
- atualizarMonitor()
- turtle.dig()
- if(turtle.forward()) then -- Proteรงรฃo contra gravel
- passos = passos+1
- else
- andar()
- end
- end
- function checarMinerio()
- if (block ~= nil) then
- if (block["name"] == "minecraft:gold_ore" or block["name"] == "minecraft:diamond_ore" or block["name"] == "minecraft:iron_ore" or block["name"] == "minecraft:deepslate_iron_ore" or block["name"] == "minecraft:deepslate_gold_ore" or block["name"] == "minecraft:deepslate_diamond_ore") then
- encontrados = encontrados+1
- turtle.select(2)
- turtle.placeDown()
- end
- end
- end
- function minerar()
- local isBlock, block = turtle.inspect()
- checarMinerio()
- andar()
- local isBlock, block = turtle.inspectUp()
- checarMinerio()
- turtle.digUp()
- local isBlock, block = turtle.inspect()
- turtle.digDown()
- checarMinerio()
- if(counter >= 20) then
- counter = 0
- droparPedra()
- else
- counter = counter+1
- end
- atualizarMonitor()
- end
- -- MAIN
- turtle.select(1)
- turtle.refuel()
- for i=1, 33 do
- -- Principal
- estado = "Cavando - principal"
- for j=1, 6 do
- minerar()
- end
- -- Esquerda
- turtle.turnLeft()
- estado = "Cavando - esquerda"
- for j=1, 5 do
- minerar()
- end
- turtle.turnRight()
- turtle.turnRight()
- estado = "Voltando - esquerda"
- for j=1, 5 do
- andar()
- end
- -- Direita
- estado = "Cavando - direita"
- for j=1, 5 do
- minerar()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- estado = "Voltando - direita"
- for j=1, 5 do
- andar()
- end
- -- Endireitando
- turtle.turnRight()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, 198 do
- estado = "Voltando - principal"
- andar()
- atualizarMonitor()
- end
Advertisement
Add Comment
Please, Sign In to add comment