Advertisement
Wassaa

extractor 2.0

Jan 8th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. local chest = peripheral.wrap("back")
  2. --local oreExt = peripheral.wrap("extractor_6")   -- ore extractor
  3. --local dustExt = peripheral.wrap("extractor_7") -- dust extractor
  4. local size = chest.getInventorySize()
  5. local oresDir = "south"
  6. local dustsDir = "north"
  7.  
  8. local oArray = {"15:0", --iron ore
  9.                      "30888:17", --iron solution
  10.                      "14:0", --gold
  11.                      "30888:18",
  12.                      "2001:1", -- tin
  13.                      "30900:2",--tin
  14.                      "2001:2",-- silver
  15.                      "30900:18",
  16.                      "2001:0", --copper
  17.                      "30900:6",
  18.                      "1060:0" -- copper
  19.                      }
  20. local dArray =  {"30888:1", --iron dust
  21.                      "30888:9", --iron slurry
  22.                      "30888:2", --gold dust
  23.                      "30888:10",
  24.                      "30900:1", --tin dust
  25.                      "30900:0",
  26.                      "30900:16",--silver
  27.                      "30900:17",
  28.                      "30900:4",--copper
  29.                      "30900:5"}
  30. print("size is: " .. size)
  31. --see if item is extractable
  32. function isOre(ore)
  33.     for k,v in pairs(oArray) do
  34.       if (ore == v) then
  35.         return true
  36.       end
  37.     end
  38.     return false
  39. end
  40. function isDust(dust)
  41.     for x,y in pairs(dArray) do
  42.       if (dust == y) then
  43.         return true
  44.       end
  45.     end
  46.     return false
  47. end
  48. --isOre(15)
  49. --loop throught the inventory
  50. function sendStuff()
  51.     chest.condenseItems()
  52.     for i=1,size do
  53.         --print (i)
  54.         local id = chest.getStackInSlot(i)
  55.         if (id ~= nil) then
  56.             local combID = tostring(id["id"])..":"..tostring(id["dmg"])
  57.             --print (combID)
  58.             --print (type(combID))
  59.             if (isOre(combID)) then
  60.                 --print(id["name"])
  61.                 chest.pushItem(oresDir,i,64)
  62.             elseif (isDust(combID)) then
  63.                 --print(id["name"])
  64.                 chest.pushItem(dustsDir,i,64)
  65.             end
  66.         end
  67.     end
  68. end
  69.  
  70. while true do
  71.     sendStuff()
  72. end
  73. --function pullOres(slot)
  74. --    oreExt.pushItem(dustsDir, slot, 64)
  75. --end
  76. --function pullDusts(slot)
  77. --   dustExt.pushItem(oresDir, slot, 64)
  78. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement