CultistaDeCrocs

branchMine

Sep 15th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.96 KB | None | 0 0
  1. local encontrados = 0
  2. local counter = 0
  3. local passos = 0
  4. local estado = "Esperando"
  5.  
  6. local tamanhoTronco = 6
  7. local tamanhoGalho = 5
  8. local tamanhoSegmento = tamanhoTronco+(tamanhoGalho*4)
  9.  
  10. local asshat = require("libraries.asshat")
  11. local minerios = {"minecraft:gold_ore", "minecraft:diamond_ore", "minecraft:iron_ore"}
  12.  
  13. if (procuraModem()) then
  14.     protocolo = "teste"
  15.     rednet.open("right")
  16. end
  17.  
  18.  
  19. function imprimirInformacao()  
  20.     printSync("Ores found: "..encontrados)
  21.     printSync("Steps until dumping: "..20-counter)
  22.     printSync("Blocks travelled: "..passos.."/"..tamanhoTotal)
  23.     printSync("")
  24.     printCor(estado, colors.lightBlue)
  25.    
  26.     imprimirCombustivel()
  27. end
  28.  
  29. function andar()
  30.     atualizarMonitor(imprimirInformacao)
  31.     turtle.dig()
  32.  
  33.     if(turtle.forward()) then -- Proteรงรฃo contra gravel
  34.         passos = passos+1
  35.     else
  36.         andar()
  37.     end
  38. end
  39.  
  40. function checarMinerio()
  41.     if (block ~= nil) then
  42.         if (existeEm(block["name"], minerios)) then
  43.             encontrados = encontrados+1
  44.             turtle.select(2)
  45.             turtle.placeDown()
  46.         end
  47.     end
  48. end
  49.  
  50. function minerar()
  51.     local isBlock, block = turtle.inspect()
  52.     checarMinerio()
  53.     andar()
  54.  
  55.     local isBlock, block = turtle.inspectUp()
  56.     checarMinerio()
  57.     turtle.digUp()
  58.  
  59.     local isBlock, block = turtle.inspect()
  60.     turtle.digDown()
  61.     checarMinerio()
  62.  
  63.     if(counter >= 20) then
  64.         counter = 0
  65.         jogaLixoFora()
  66.     else
  67.         counter = counter+1
  68.     end
  69.     atualizarMonitor(imprimirInformacao)
  70. end
  71.  
  72.  
  73. -- MAIN
  74.  
  75. informacaoTitulo("B R A N C H  M I N E")
  76.  
  77. writeSync("I will mine segments ")
  78. writeCor("6", colors.orange)
  79. writeSync(" blocks long with branches ")
  80. writeCor("10", colors.orange)
  81. writeSync(" blocks long.")
  82. writeCor(" How many segments should I mine?", colors.lightBlue)
  83. numSegmentos = lerNumero()
  84.  
  85. tamanhoIda = tamanhoSegmento*numSegmentos
  86. tamanhoVolta = tamanhoTronco*numSegmentos
  87. tamanhoTotal = tamanhoIda+tamanhoVolta
  88.  
  89. informacaoCombustivelNecessario(tamanhoTotal)
  90.  
  91. turtle.select(1)
  92. turtle.refuel()
  93.  
  94. for i=1, numSegmentos do
  95.     -- Principal
  96.     estado = "Digging - Main"
  97.     for j=1, tamanhoTronco do
  98.         minerar()
  99.     end
  100.  
  101.     -- Esquerda
  102.     turtle.turnLeft()
  103.     estado = "Digging - Left"
  104.     for j=1, tamanhoGalho do
  105.         minerar()
  106.     end
  107.     turtle.turnRight()
  108.     turtle.turnRight()
  109.     estado = "Returning - Left"
  110.     for j=1, tamanhoGalho do
  111.         andar()
  112.     end
  113.    
  114.     -- Direita
  115.     estado = "Digging - Right"
  116.     for j=1, tamanhoGalho do
  117.         minerar()
  118.     end
  119.     turtle.turnLeft()
  120.     turtle.turnLeft()
  121.     estado = "Returning - Right"
  122.     for j=1, tamanhoGalho do
  123.         andar()
  124.     end
  125.  
  126.     -- Endireitando
  127.     turtle.turnRight()
  128. end
  129.  
  130. turtle.turnLeft()
  131. turtle.turnLeft()
  132.  
  133. for i=1, tamanhoVolta do
  134.     estado = "Returning - Main"
  135.     andar()
  136.     atualizarMonitor(imprimirInformacao)
  137. end
  138.  
  139. agradece(passos)
Add Comment
Please, Sign In to add comment