Advertisement
Wassaa

extractor 3.0

Jan 9th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local chest = peripheral.wrap("gold_1")
  2. local extractor = peripheral.wrap("container_chest_1")
  3. --local oreExt = peripheral.wrap("extractor_6")   -- ore extractor
  4. local size = chest.getInventorySize()
  5. local oresDir = "north"
  6. local backDir = "north"
  7. local oresToPush = {}
  8. local ores = {"15:0","14:0", "2001:0"}
  9.  
  10. print("size is: " .. size)
  11. --see if item is extractable
  12. function isOre(ore)
  13.     for k,v in pairs(ores) do
  14.       if (ore == v) then
  15.         return true
  16.       end
  17.     end
  18.     return false
  19. end
  20.  
  21. --loop throught the inventory
  22. function stuffToSend()
  23.     --chest.condenseItems()
  24.     for i=1,size do
  25.         --print (i)
  26.         local id = chest.getStackInSlot(i)
  27.         if (id ~= nil) then
  28.             local combID = tostring(id["id"])..":"..tostring(id["dmg"])
  29.             local iName = tostring(id["name"])
  30.             --print (combID)
  31.             print (iName)
  32.             if isOre(combID) and string.find(iName, "Ore") ~= nil then
  33.                 --print(id["name"])
  34.                 local leng = table.getn(oresToPush) + 1
  35.                 oresToPush[leng] = i
  36.                 --chest.pushItem(oresDir,i,64)
  37.             end
  38.         end
  39.     end
  40.     sendStuff()
  41. end
  42.  
  43.  
  44. function sendStuff()
  45.     if table.getn(oresToPush) ~= 0 then
  46.         for k,v in pairs(oresToPush) do
  47.             print (chest.getStackInSlot(v)["name"])
  48.             while chest.getStackInSlot(v) ~= nil do
  49.                 chest.pushItem(oresDir,v,64)
  50.                 os.sleep(0.5)
  51.                 print ("loop")
  52.             end
  53.         end
  54.     end
  55.     oresToPush = {}
  56. end
  57.  
  58.  
  59.  
  60.     stuffToSend()
  61.  
  62. --function pullOres(slot)
  63. --    oreExt.pushItem(dustsDir, slot, 64)
  64. --end
  65. --function pullDusts(slot)
  66. --   dustExt.pushItem(oresDir, slot, 64)
  67. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement