Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- estadosQuarry =
- {
- [0] = "Cavando",
- [1] = "Falta de combustível provável",
- [2] = "Bedrock provável",
- [3] = "Subindo",
- }
- inverteDirecao = false
- tamanhoLado = 5
- maxDropar = 20
- counterDropar = 0
- passosLinha = 0
- passosCamada = 1
- passosCubo = 1
- passosGeral = 0
- camada = 1
- escolhaModo = 1
- areaCubo = 1
- estadoQuarry = 0
- alturaLinha = 0
- comprimentoTunel = 0
- cuboAtual = 0
- local asshat = require("libraries.asshat")
- function informacaoCubo()
- printSync("Layer: "..camada)
- printSync("Steps until dump: "..maxDropar-counterDropar)
- printSync("Blocks traveled: "..passosGeral.."/"..(areaCubo)-1)
- printSync("Blocks traveled (layer): "..passosCamada.."/"..(tamanhoLado^2)-1)
- printSync("Blocks traveled (line): "..passosLinha.."/"..tamanhoLado-1)
- printBool("Inverted direction", inverteDirecao)
- end
- function informacaoQuarry()
- printSync("Steps until dump: "..maxDropar-counterDropar)
- printSync("Blocks traveled: "..passosGeral.."/?")
- writeSync("Status: ")
- printCor(estadosQuarry[estadoQuarry], colors.blue)
- end
- function informacaoTunelHorizontal()
- printSync("Layer: "..camada)
- printSync("Steps until dump: "..maxDropar-counterDropar)
- printSync("Blocks traveled (cube): "..passosCubo.."/"..(tamanhoLado^3)-1)
- printSync("Blocks traveled (layer): "..passosCamada.."/"..(tamanhoLado^2)-1)
- printSync("Blocks traveled (line): "..passosLinha.."/"..tamanhoLado-1)
- printSync("Cubes dug: "..cuboAtual.."/"..comprimentoTunel)
- printBool("Inverted direction", inverteDirecao)
- end
- function imprimirInformacao()
- funcoesInformacao =
- {
- [1] = informacaoCubo,
- [2] = informacaoCubo,
- [3] = informacaoTunelHorizontal,
- [4] = informacaoQuarry,
- }
- funcoesInformacao[escolhaModo]()
- imprimirCombustivel()
- end
- function cavar()
- if(turtle.dig()) then
- counterDropar = counterDropar + 1
- end
- end
- function cavarBaixo()
- if(turtle.digDown()) then
- counterDropar = counterDropar + 1
- return true
- end
- end
- function cavarCima()
- if(turtle.digUp()) then
- counterDropar = counterDropar + 1
- end
- end
- function aumentaPassos()
- passosLinha = passosLinha+1
- passosCamada = passosCamada+1
- passosCubo = passosCubo+1
- passosGeral = passosGeral+1
- end
- function andar()
- atualizarMonitor(imprimirInformacao)
- cavar()
- if(not(turtle.forward())) then -- Proteção contra gravel
- andar()
- else
- aumentaPassos()
- end
- end
- function andarCima()
- atualizarMonitor(imprimirInformacao)
- cavarCima()
- if(not(turtle.up())) then -- Proteção contra gravel
- andarCima()
- else
- aumentaPassos()
- end
- end
- function cavaLinha()
- for i=1, tamanhoLado-1 do
- andar()
- if (counterDropar >= maxDropar) then
- jogaLixoFora()
- end
- end
- passosLinha = 0
- end
- function cavaCamada()
- for i=1, tamanhoLado do
- cavaLinha()
- if (i ~= tamanhoLado) then
- if (inverteDirecao) then
- turtle.turnLeft()
- andar()
- turtle.turnLeft()
- inverteDirecao = false
- else
- turtle.turnRight()
- andar()
- turtle.turnRight()
- inverteDirecao = true
- end
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- function posicionaProximoCubo()
- if (tamanhoLado%2 == 1) then
- turtle.turnRight()
- end
- for i=1, tamanhoLado-1 do
- andar()
- andarCima()
- end
- if (tamanhoLado%2 == 1) then
- turtle.turnRight()
- end
- andar()
- passosLinha = 0
- passosCamada = 1
- camada = 1
- end
- function cavaCubo ()
- for i=1, tamanhoLado do
- cavaCamada()
- if(i ~= tamanhoLado) then
- turtle.digDown()
- turtle.down()
- aumentaPassos()
- atualizarMonitor(imprimirInformacao)
- passosLinha = 0
- passosCamada = 1
- end
- camada = camada+1
- end
- end
- function cavaTunelVertical ()
- for i=1, alturaTunel do
- cavaCamada()
- if(i ~= tamanhoLado) then
- turtle.digDown()
- turtle.down()
- aumentaPassos()
- atualizarMonitor(imprimirInformacao)
- passosLinha = 0
- passosCamada = 1
- end
- camada = camada+1
- end
- end
- function cavaTunelHorizontal ()
- for i=1, comprimentoTunel do
- cavaCubo()
- posicionaProximoCubo()
- cuboAtual = cuboAtual+1
- passosCubo = 0
- end
- end
- function cavaTunelCustomizado ()
- for i=1, comprimentoTunel do
- cavaTunelVertical()
- posicionaProximoCubo()
- cuboAtual = cuboAtual+1
- passosCubo = 0
- end
- end
- function cavaQuarry ()
- for i=1, tamanhoLado do
- for i=1, tamanhoLado do
- coluna()
- turtle.turnRight()
- andar()
- turtle.turnLeft()
- end
- andar()
- turtle.turnLeft()
- for i=1, tamanhoLado do
- andar()
- end
- turtle.turnRight()
- end
- end
- function cavarBaixo()
- if(turtle.digDown()) then
- counterDropar = counterDropar + 1
- return true
- else
- return false
- end
- end
- function cavaColuna()
- atualizarMonitor(imprimirInformacao)
- if (counterDropar >= maxDropar) then
- jogaLixoFora()
- end
- if estadoQuarry ~= 3 then
- estadoQuarry = 0
- end
- if cavarBaixo() == false then
- estadoQuarry = 1
- end
- if turtle.down() == false then
- if estadoQuarry == 0 then
- estadoQuarry = 1
- atualizarMonitor(imprimirInformacao)
- turtle.select(1)
- turtle.refuel(1)
- else
- estadoQuarry = 2
- end
- else
- alturaLinha = alturaLinha + 1
- passosGeral = passosGeral + 1
- end
- if estadoQuarry == 2 then
- for i=1, alturaLinha do
- atualizarMonitor(imprimirInformacao)
- if turtle.up() == false then
- turtle.digUp()
- turtle.select(1)
- turtle.refuel(1)
- else
- passosGeral = passosGeral + 1
- end
- end
- estadoQuarry = 3
- atualizarMonitor(imprimirInformacao)
- end
- end
- function coluna()
- while estadoQuarry ~= 3 do
- cavaColuna()
- end
- estadoQuarry = 0
- alturaLinha = 0
- end
- function perguntaCubo()
- printCor("What's the size of the cube?", colors.orange)
- tamanhoLado = lerNumero()
- areaCubo = tamanhoLado^3
- informacaoCombustivelNecessario((areaCubo) - 1)
- end
- function perguntaTunelVertical()
- printCor("What's the size of the tunnel's sides?", colors.orange)
- tamanhoLado = lerNumero()
- printCor("What's the tunnel's height?", colors.orange)
- alturaTunel = lerNumero()
- areaCubo = (tamanhoLado^2)*alturaTunel
- informacaoCombustivelNecessario((areaCubo) - 1)
- end
- function perguntaTunelHorizontal()
- printCor("What's the size of the cube's sides?", colors.orange)
- tamanhoLado = lerNumero()
- printCor("How many cubes long should the tunnel be?", colors.orange)
- comprimentoTunel = lerNumero()
- end
- function perguntaQuarry ()
- printCor("What's the size of the quarry's sides?", colors.orange)
- tamanhoLado = lerNumero()
- end
- function perguntaValores()
- funcoesPergunta =
- {
- [1] = perguntaCubo,
- [2] = perguntaTunelVertical,
- [3] = perguntaTunelHorizontal,
- [4] = perguntaQuarry,
- }
- funcoesPergunta[escolhaModo]()
- end
- function executaEscolha()
- funcoesCava =
- {
- [1] = cavaCubo,
- [2] = cavaTunelVertical,
- [3] = cavaTunelHorizontal,
- [4] = cavaQuarry,
- }
- funcoesCava[escolhaModo]()
- jogaLixoFora()
- end
- -- Main
- informacaoTitulo("E X C A V A T O R")
- print("Choose excavation mode:\n")
- imprimirTabela({"Perfect cube", "Variable-height cube", "Variable-depth cube", "Quarry"})
- escolhaModo = pedeEscolha(4)
- perguntaValores()
- executaEscolha()
- agradece(passosGeral)
Add Comment
Please, Sign In to add comment