Advertisement
Guest User

minar

a guest
Apr 7th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | None | 0 0
  1. nivelesVaciar = 3
  2.  
  3. local arg = { ... }
  4. if (tonumber(arg[1])) then
  5.     argumento = tonumber(arg[1])
  6. else
  7.     print("Introduce un numero")
  8.     return
  9. end
  10.  
  11. if argumento then
  12.     if (argumento < 0) then
  13.         print("Introduce un numero positivo e impar")
  14.         return    
  15.     else
  16.         if (argumento % 2 == 1) then
  17.             radioOriginal = argumento
  18.         else
  19.             print("Introduce un numero impar")
  20.             return
  21.         end
  22.     end
  23. else
  24.     print("Introduce un radio - Tiene que ser un numero impar")
  25.     return
  26. end
  27.  
  28. profundidad = 0
  29. contadorNiveles = 0
  30. vueltas = 3
  31. radio = radioOriginal
  32.  
  33. function Combustible()
  34.     for i=1,16 do
  35.         turtle.select(i)
  36.         turtle.refuel()
  37.     end
  38.     turtle.select(1)
  39. end
  40.  
  41. function MinarLinea(n)
  42.     for i=1, n do
  43.         if (not turtle.dig()) then
  44.             if (not turtle.forward()) then
  45.                 return false
  46.             end
  47.         else
  48.             turtle.forward()
  49.         end
  50.     end
  51.     return true
  52. end
  53.  
  54. function Recolocar()
  55.     for i=1,(radioOriginal+1)/2 do
  56.         turtle.forward()
  57.     end
  58.     turtle.turnLeft()
  59.     for i=1,(radioOriginal-1)/2 do
  60.         turtle.forward()
  61.     end
  62.     turtle.turnRight()
  63.     turtle.turnRight()    
  64. end
  65.  
  66. function MinarNivel()
  67.     if (not turtle.digDown()) then
  68.         if (not turtle.down()) then
  69.             return false
  70.         end
  71.     else
  72.         turtle.down()
  73.     end
  74.     profundidad = profundidad + 1
  75.    
  76.     while vueltas>0 do
  77.         if (not MinarLinea(radio)) then
  78.             return false
  79.         end
  80.         vueltas = vueltas - 1
  81.         if (vueltas == 0) then
  82.             radio = radio - 1
  83.             if (radio == 0) then
  84.                 vueltas = 0
  85.             else
  86.                 vueltas = 2
  87.             end    
  88.          end
  89.         turtle.turnRight()
  90.     end
  91.     radio = radioOriginal
  92.     vueltas = 3
  93.     contadorNiveles = contadorNiveles + 1
  94.     return true
  95. end
  96.  
  97. function Vaciar()
  98.     for i=1, profundidad+1 do
  99.         turtle.up()
  100.     end
  101.     turtle.back()
  102.    
  103.     for i=1,16 do
  104.         turtle.select(i)
  105.         turtle.dropDown()
  106.     end
  107.    
  108.     turtle.forward()
  109.     for i=1, profundidad+1 do
  110.         turtle.down()
  111.     end
  112.     contadorNiveles = 0
  113. end
  114.  
  115. function Terminar()
  116.     for i=1, profundidad+1 do
  117.         turtle.up()
  118.     end
  119. end
  120.  
  121. function SoltarMierda()
  122.     for i=1, 16 do
  123.         detalles = turtle.getItemDetail(i)
  124.         if (detalles) then
  125.             if (detalles.name == "minecraft:cobblestone") then
  126.                 turtle.select(i)
  127.                 turtle.drop()
  128.             end
  129.         end
  130.     end
  131.     turtle.select(1)
  132. end          
  133.  
  134. function execute()
  135.     Combustible()
  136.    
  137.     while contadorNiveles < nivelesVaciar do
  138.         if (not MinarNivel()) then
  139.             Terminar()
  140.             return
  141.         end
  142.         Recolocar()
  143.         Combustible()
  144.         SoltarMierda()
  145.     end
  146.    
  147.     Vaciar()
  148.     return true    
  149. end
  150.  
  151.  
  152. while true do
  153.     if (not execute()) then
  154.         break
  155.     end
  156. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement