Bardiel

[ComputerCraft] Turtle Inventory Management

Sep 20th, 2012
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. --Power by Bardiel-- [email protected]
  2. --http://www.youtube.com/user/BardielHachiSan
  3.  
  4. local tArgs = { ... }
  5.  
  6. if tonumber (tArgs[1]) then
  7.     slot = tonumber (tArgs[1])
  8. else
  9.     slot = -1
  10. end
  11.  
  12. arriba = false
  13.  
  14. if turtle.detectDown() then
  15.     for c = 1 , 15 do
  16.         if ( turtle.getItemCount( c ) > 0 ) and ( turtle.getItemSpace( c ) > 0 )then
  17.             turtle.select( c )
  18.             siguiente = c + 1
  19.             for t = siguiente , 16 do
  20.                 if turtle.compareTo( t ) and (turtle.getItemSpace( c ) > 0) then
  21.                     faltante = turtle.getItemSpace( c )
  22.                     turtle.select( t )
  23.                     if not arriba then
  24.                         turtle.up()
  25.                         arriba = true
  26.                     end
  27.                     turtle.dropDown(faltante)
  28.                     turtle.select( c )
  29.                     turtle.suckDown()
  30.                 end
  31.             end
  32.             if arriba then
  33.                 turtle.down()
  34.                 arriba = false
  35.             end
  36.         end
  37.     end
  38. else
  39.     write ("Debo tener suelo debajo de mi para realizar esta tarea!/n")
  40. end
  41.  
  42. if slot > 0 and slot < 17 then
  43.     turtle.select( slot )
  44. end
  45.  
  46. for c = 1 , 16 do
  47.     if turtle.getItemCount( c ) == 0 then
  48.         return true
  49.     end
  50. end
  51.  
  52.  
  53. return false
  54. --Power by Bardiel-- [email protected]
Advertisement
Add Comment
Please, Sign In to add comment