Guest User

delilahtw01

a guest
Feb 14th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.89 KB | None | 0 0
  1. local dx = 10
  2. local dz = 10
  3. local a = 0
  4. local distbx = 11
  5. local distfx = 0
  6. local distfz = 0
  7. local cz = 0
  8. local cy = 0
  9. local czy = 0
  10. local ait1 = 0
  11. local ait2 = 0
  12. local ait3 = 0
  13.  
  14. -- Funcion Fuel
  15. function fuel()
  16.    
  17.         -- miramos inventario para chequear fuel
  18.         turtle.select(1)
  19.         a = 0
  20.         for a = 2,16 do
  21.                 if turtle.compareTo(a) then
  22.                                        
  23.                     -- compruebo items primer slot, muevo y recargo fuel.
  24.                     turtle.select(1)
  25.                    
  26.                     if turtle.getItemCount(1) < 10 then
  27.                         -- Transfers 32 items from the selected slot to slot 6.
  28.                         -- turtle.transferTo(6, 32)
  29.                         -- turtle.transferTo(slot destino,cantidad)
  30.                         -- Cogemos un carbon del slot selecionado turtle.select(a) y lo ponemos en slot (1)
  31.                         turtle.select(a)   
  32.                         turtle.transferTo(1, 1)
  33.                                                
  34.                     end
  35.                
  36.                 end
  37.         end
  38.    
  39.     if turtle.getFuelLevel() < 1 then
  40.         turtle.refuel(1)
  41.     end
  42.        
  43. end
  44.  
  45. -- Funcion cavax
  46. function cavax()
  47.  
  48.     repeat
  49.         fuel()
  50.         if turtle.forward() then
  51.             distfx = distfx +1
  52.         end
  53.         turtle.dig()
  54.     until distfx == dx
  55.  
  56.     if distfx == dx then
  57.        
  58.         distfz = distfz + 1
  59.        
  60.         repeat
  61.             fuel()
  62.             if turtle.back() then
  63.                 distbx = distbx - 1
  64.             end
  65.         until distbx == 1
  66.        
  67.         distbx = 11
  68.         distfx = 0
  69.         dx = 10
  70.        
  71.         cavaz()
  72.        
  73.     end
  74.  
  75. end
  76.  
  77. -- Funcion cavaz
  78. function cavaz()
  79.    
  80.     if distfz == dz then
  81.         distfz = 1
  82.         turtle.turnLeft()
  83.        
  84.         repeat
  85.             fuel()
  86.             if turtle.forward() then
  87.                 distfz = distfz +1
  88.             end
  89.         until distfz == dz
  90.            
  91.         turtle.turnRight() 
  92.         distfz = 0
  93.         cz = 0
  94.         dz = 10
  95.                
  96.         cavay()
  97.        
  98.     end
  99.  
  100.     if czy ~= 1 then
  101.         cz = 0
  102.         turtle.turnRight()
  103.         turtle.dig()
  104.        
  105.             repeat
  106.                 if turtle.forward() then
  107.                     cz = cz +1
  108.                 end
  109.             until cz == 1
  110.        
  111.         turtle.turnLeft()
  112.     end
  113.    
  114.     czy = 0
  115.        
  116. end
  117.  
  118. function cavay()
  119.  
  120.     fuel()
  121.     turtle.digDown()
  122.    
  123.     cy = 0
  124.     repeat
  125.         if turtle.down() then
  126.             cy = cy +1
  127.             if cy == 256 then
  128.                     os.shutdown()
  129.             end
  130.         end
  131.     until cy == 1
  132.    
  133.     -- reset de variables.
  134.     dx = 10
  135.     dz = 10
  136.     distbx = 11
  137.     distfx = 0
  138.     distfz = 0
  139.     cz = 0
  140.     cy = 0
  141.     czy = 1
  142.    
  143.     -- tiramos tierra, piedra y grava
  144.    
  145.         turtle.select(2)
  146.         ait1 = 0
  147.         for ait1 = 5,16 do
  148.                 if turtle.compareTo(ait1) then
  149.        
  150.                         turtle.getItemCount(ait1)
  151.                         turtle.select(ait1)
  152.                         turtle.drop()                      
  153.                                                                    
  154.                 end
  155.                 turtle.select(2)
  156.         end
  157.        
  158.         turtle.select(3)
  159.         ait2 = 0
  160.         for ait2 = 5,16 do
  161.                 if turtle.compareTo(ait2) then
  162.        
  163.                         turtle.getItemCount(ait2)
  164.                         turtle.select(ait2)
  165.                         turtle.drop()                      
  166.                                                                    
  167.                 end
  168.                 turtle.select(3)
  169.         end
  170.        
  171.         turtle.select(4)
  172.         ait3 = 0
  173.         for ait3 = 5,16 do
  174.                 if turtle.compareTo(ait3) then
  175.        
  176.                         turtle.getItemCount(ait3)
  177.                         turtle.select(ait3)
  178.                         turtle.drop()                      
  179.                                                                    
  180.                 end
  181.                 turtle.select(4)
  182.         end
  183.        
  184. end
  185.  
  186. -- Empezamos el programa
  187.  
  188. fuel()
  189.  
  190. while true do
  191.  
  192.     cavax()
  193.    
  194. end
Advertisement
Add Comment
Please, Sign In to add comment