Advertisement
Guest User

prueba

a guest
Apr 24th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. local height = 0
  2. local start = 0
  3.  
  4. local function fuel()
  5.     if turtle.getFuelLevel() < 100 then
  6.         turtle.select(15)
  7.         numero = turtle.getItemCount(15)
  8.         if numero == 1 then
  9.             toSurface()
  10.             print "error"
  11.             error()
  12.         else
  13.             turtle.refuel(numero-1)
  14.             fuel()
  15.         end
  16.     end
  17. end
  18.  
  19. function toSurface()
  20.     turtle.select(4)
  21.     while height < start do
  22.         while turtle.detectUp() do
  23.             if turtle.compareUp() then
  24.                 suckChestUp()
  25.             end
  26.             turtle.digUp()
  27.         end
  28.         turtle.up()
  29.         height = height+1
  30.     end
  31. end
  32.    
  33. function inventoryFull()
  34.     local exit = true
  35.     for i=1, 16 do
  36.         if turtle.getItemCount(i) == 0 then
  37.             exit = false
  38.         end
  39.     end
  40.     return exit
  41. end
  42.  
  43. function suckChestUp()
  44.   repeat
  45.     if inventoryFull() then
  46.         print "pru"
  47.         turtle.digDown()
  48.         turtle.select(16)
  49.         turtle.placeDown()
  50.         for i=5, 14 do
  51.             turtle.select(i)
  52.             turtle.dropDown()
  53.         end
  54.         sleep(5)
  55.         turtle.select(16)
  56.         turtle.digDown()
  57.         turtle.select(4)
  58.         suckChestUp()
  59.     else
  60.      salida =  turtle.suckUp()
  61.     end
  62.     until salida == false
  63. end
  64.  
  65. prueba = tonumber(read())
  66. start = prueba
  67. height = prueba-4
  68. fuel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement