Advertisement
Guest User

ex

a guest
Jan 7th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. local chest = peripheral.wrap("right")
  2. local size = chest.getInventorySize()
  3. local oresDir = "south"
  4. local dustsDir = "north"
  5. chest.condenseItems()
  6.  
  7. local oArray = {"15:0", --iron ore
  8.                      "30888:17", --iron solution
  9.                      "14:0", --gold
  10.                      "30888:18"}
  11. local dArray =  {"30888:1", --iron dust
  12.                      "30888:9", --iron slurry
  13.                      "30888:2", --gold dust
  14.                      "30888:10"}
  15. print("size is: " .. size)
  16. --pulled = chest.pullItemIntoSlot("west", 1, 64, 1)
  17. --pushed = chest.pushItemIntoSlot("west", 1, 64, 1)
  18. --print(pushed)
  19. --see if item is extractable
  20. function isOre(ore)                                          
  21.     for k,v in pairs(oArray) do
  22.       if (ore == v) then
  23.         return true
  24.       end
  25.     end
  26.     return false
  27. end
  28.  
  29. function isDust(dust)                                    
  30.     for x,y in pairs(dArray) do
  31.       if (dust == y) then
  32.         return true
  33.       end
  34.     end
  35.     return false
  36. end
  37.  
  38. --isOre(15)  
  39.  
  40. --loop throught the inventory
  41. for i=1,size do
  42.   print (i)
  43.   local id = chest.getStackInSlot(i)
  44.   if (id ~= nil) then
  45.     local combID = tostring(id["id"])..":"..tostring(id["dmg"])
  46.     --print (combID)
  47.     --print (type(combID))
  48.       if (isOre(combID)) then
  49.          --print(id["name"])
  50.          chest.pushItem(oresDir,i,64)
  51.     elseif (isDust(combID)) then
  52.        --print(id["name"])
  53.        chest.pushItem(dustsDir,i,64)
  54.      end
  55.  
  56.   end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement