Advertisement
ecco7777

CC furnace array

Mar 22nd, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. inventoryName="tile_extrautils_chestfull_name"
  2. furnaceName="container_furnace"
  3. sides={"north","south"}
  4.  
  5. function wrapPs(peripheralName)
  6.     periTab={}
  7.     sideTab={}
  8.     if peripheralName==nil then
  9.         print("Fehler")
  10.     end
  11.     local peripherals = peripheral.getNames()
  12.     local i2 = 1
  13.     for i =1, #peripherals do
  14.         if peripheral.getType(peripherals[i])==peripheralName then
  15.             periTab[i2]=peripheral.wrap(peripherals[i])
  16.             sideTab[i2]=peripherals[i]
  17.             i2=i2+1
  18.         end
  19.     end
  20.     if periTab~={} then
  21.         return periTab,sideTab
  22.     else
  23.         return nil
  24.     end
  25. end
  26.  
  27. chests=wrapPs(inventoryName)
  28. furns=wrapPs(furnaceName)
  29.  
  30. function getSumOfItems()
  31. soi=0
  32.     for i=1, #chests do
  33.         if chests[i]~=nil then
  34.             if chests[i].getStackInSlot(1)~=nil then
  35.                 soi=soi+chests[i].getStackInSlot(1).qty
  36.             end
  37.         end
  38.     end
  39. return soi
  40. end
  41.  
  42. function evenOut()
  43.     soi=getSumOfItems()
  44.     finished=false
  45.     continue=true
  46.     while continue do
  47.     finished=true
  48.         for i=1, #chests do
  49.             if chests[i]~=nil then
  50.                 if chests[i].getStackInSlot(1)~=nil then
  51.                     if chests[i].getStackInSlot(1).qty>soi/#chests then
  52.                         soi=soi+chests[i].pushItemIntoSlot(sides[math.random(2)],1,1,1)
  53.                         finished=false
  54.                     end
  55.                 end
  56.             end
  57.         end
  58.         if finished==true then
  59.             continue=false
  60.         end
  61.     end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement