CultistaDeCrocs

SeussBranchMine

Jul 22nd, 2022 (edited)
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.44 KB | None | 0 0
  1. local encontrados = 0
  2. local counter = 0
  3. local passos = 0
  4. local estado = "Esperando"
  5.  
  6. function printCor(texto, cor) -- Imprime o texto com a cor desejada, depois volta pra branco.
  7.     term.setTextColor(cor)
  8.     print(texto)
  9.     term.setTextColor(colors.white)
  10. end
  11.  
  12. function atualizarMonitor()
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15.    
  16.     printCor("=============================", colors.yellow)
  17.     printCor("I N F O R M A C O E S", colors.orange)
  18.     imprimirInformacao()
  19.     printCor("=============================", colors.yellow)
  20. end
  21.  
  22. function imprimirInformacao()
  23.     if(turtle.getFuelLevel() > 0) then
  24.         print("Combustivel: "..turtle.getFuelLevel())
  25.     else
  26.         term.setTextColor(colors.red)
  27.         print("Combustivel: "..turtle.getFuelLevel())
  28.         term.setTextColor(colors.white)
  29.     end
  30.    
  31.     print("Minerios encontrados: "..encontrados)
  32.     print("Passos atรฉ dropar: "..20-counter)
  33.     print("Passos andados: "..passos.."/858")
  34.     print("")
  35.     printCor(estado, colors.lightBlue)
  36. end
  37.  
  38. function droparPedra()
  39.     for i=1, 16 do
  40.         turtle.select(i)
  41.         if(turtle.getItemDetail()) then
  42.             if turtle.getItemDetail().name == "minecraft:cobblestone" then
  43.                 turtle.drop()
  44.             elseif turtle.getItemDetail().name == "minecraft:stone" then
  45.                 turtle.drop()
  46.             elseif turtle.getItemDetail().name == "minecraft:dirt" then
  47.                 turtle.drop()
  48.             elseif turtle.getItemDetail().name == "minecraft:gravel" then
  49.                 turtle.drop()
  50.             elseif turtle.getItemDetail().name == "minecraft:cobbled_deepslate" then
  51.                 turtle.drop()
  52.             elseif turtle.getItemDetail().name == "minecraft:diorite" then
  53.                 turtle.drop()
  54.             elseif turtle.getItemDetail().name == "minecraft:andesite" then
  55.                 turtle.drop()
  56.             elseif turtle.getItemDetail().name == "minecraft:tuff" then
  57.                 turtle.drop()
  58.             end
  59.         end
  60.     end
  61.     turtle.select(1)
  62. end
  63.  
  64. function andar()
  65.     atualizarMonitor()
  66.     turtle.dig()
  67.  
  68.     if(turtle.forward()) then -- Proteรงรฃo contra gravel
  69.         passos = passos+1
  70.     else
  71.         andar()
  72.     end
  73. end
  74.  
  75. function checarMinerio()
  76.     if (block ~= nil) then
  77.         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
  78.             encontrados = encontrados+1
  79.             turtle.select(2)
  80.             turtle.placeDown()
  81.         end
  82.     end
  83. end
  84.  
  85. function minerar()
  86.     local isBlock, block = turtle.inspect()
  87.     checarMinerio()
  88.     andar()
  89.  
  90.     local isBlock, block = turtle.inspectUp()
  91.     checarMinerio()
  92.     turtle.digUp()
  93.  
  94.     local isBlock, block = turtle.inspect()
  95.     turtle.digDown()
  96.     checarMinerio()
  97.  
  98.     if(counter >= 20) then
  99.         counter = 0
  100.         droparPedra()
  101.     else
  102.         counter = counter+1
  103.     end
  104.     atualizarMonitor()
  105. end
  106.  
  107.  
  108. -- MAIN
  109.  
  110. turtle.select(1)
  111. turtle.refuel()
  112.  
  113. for i=1, 33 do
  114.     -- Principal
  115.     estado = "Cavando - principal"
  116.     for j=1, 6 do
  117.         minerar()
  118.     end
  119.  
  120.     -- Esquerda
  121.     turtle.turnLeft()
  122.     estado = "Cavando - esquerda"
  123.     for j=1, 5 do
  124.         minerar()
  125.     end
  126.     turtle.turnRight()
  127.     turtle.turnRight()
  128.     estado = "Voltando - esquerda"
  129.     for j=1, 5 do
  130.         andar()
  131.     end
  132.    
  133.     -- Direita
  134.     estado = "Cavando - direita"
  135.     for j=1, 5 do
  136.         minerar()
  137.     end
  138.     turtle.turnLeft()
  139.     turtle.turnLeft()
  140.     estado = "Voltando - direita"
  141.     for j=1, 5 do
  142.         andar()
  143.     end
  144.  
  145.     -- Endireitando
  146.     turtle.turnRight()
  147. end
  148.  
  149. turtle.turnLeft()
  150. turtle.turnLeft()
  151.  
  152. for i=1, 198 do
  153.     estado = "Voltando - principal"
  154.     andar()
  155.     atualizarMonitor()
  156. end
Advertisement
Add Comment
Please, Sign In to add comment