Advertisement
fatboychummy

PushPull

Jul 7th, 2019
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1.  
  2. -- editables
  3. local cacheExtension = 4
  4. local chestExtension = 5
  5.  
  6. -- etc
  7. local tArg = ...
  8. local chest = "minecraft:chest_" .. tostring(chestExtension)
  9. local cache = "thermalexpansion:storage_cache_" .. tostring(cacheExtension)
  10.  
  11. local function getCollectors()
  12.   local collector = "projecte:collector_"
  13.   local mks = {
  14.     "mk1",
  15.     "mk2",
  16.     "mk3"
  17.   }
  18.   local collectors = {}
  19.   local ps = peripheral.getNames()
  20.  
  21.   for i = 1, #ps do
  22.     for o = 1, #mks do
  23.       if ps[i]:find(collector .. mks[o]) then
  24.         collectors[#collectors + 1] = ps[i]
  25.         break
  26.       end
  27.     end
  28.   end
  29.  
  30.   return collectors
  31. end
  32.  
  33. local function insert()
  34.   local cols = getCollectors()
  35.   for i = 1, #cols do
  36.     peripheral.call(cache, "pushItems", cols[i], 1, 64)
  37.   end
  38. end
  39.  
  40. local function pullBack()
  41.   local cols = getCollectors()
  42.   for i = 1, #cols do
  43.     local sz = peripheral.call(cols[i], "size")
  44.     for o = 1, sz do
  45.       peripheral.call(chest, "pullItems", cols[i], o, 64)
  46.     end
  47.   end
  48. end
  49.  
  50. if not tArg then
  51.   print("Pushing")
  52.   insert()
  53.   print("Done")
  54. else
  55.   print("Pulling")
  56.   pullBack()
  57.   print("Done")
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement