JereTheJuggler

poise.lua

Dec 5th, 2021 (edited)
656
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PeripheralTypes={
  2.     insolator="thermal:machine_insolator",
  3.     drawer="standardDrawer"
  4. }
  5.  
  6. ItemNames={
  7.     tallBush="endergetic:tall_poise_bush",
  8.     bush="endergetic:poise_bush",
  9.     slime="tconstruct:ender_slime_ball",
  10.     poiseBlock="endergetic:poise_cluster"
  11. }
  12.  
  13. Peripherals={
  14.     tallBushInsolators={},
  15.     clusterInsolators={},
  16.     bushInsolators={},
  17.     tallBushDrawer=nil,
  18.     bushDrawer=nil,
  19.     slimeDrawer=nil,
  20.     poiseBlockDrawer=nil,
  21.     wrap=function(name)
  22.         local perip = peripheral.wrap(name)
  23.         perip.name = name
  24.         return perip
  25.     end,
  26.     wrapAll=function(self)
  27.         local insolatorCount = 0
  28.         for _,name in ipairs(peripheral.getNames()) do
  29.             local t = peripheral.getType(name)
  30.             if t == PeripheralTypes.insolator then
  31.                 if insolatorCount % 5 == 0 then
  32.                     table.insert(self.tallBushInsolators,self.wrap(name))
  33.                 elseif insolatorCount % 5 == 1 then
  34.                     table.insert(self.clusterInsolators,self.wrap(name))
  35.                 else
  36.                     table.insert(self.bushInsolators,self.wrap(name))
  37.                 end
  38.                 insolatorCount = insolatorCount + 1
  39.             elseif t == PeripheralTypes.drawer then
  40.                 local drawer = self.wrap(name)
  41.                 local itemName = drawer.getItemDetail(1).name
  42.                 if itemName == ItemNames.poiseBlock then
  43.                     self.poiseBlockDrawer = drawer
  44.                 elseif itemName == ItemNames.bush then
  45.                     self.bushDrawer = drawer
  46.                 elseif itemName == ItemNames.tallBush then
  47.                     self.tallBushDrawer = drawer
  48.                 elseif itemName == ItemNames.slime then
  49.                     self.slimeDrawer = drawer
  50.                 end
  51.             end
  52.         end
  53.     end
  54. }
  55.  
  56. Peripherals:wrapAll()
  57. for _,insolatorList in ipairs({"tallBushInsolators","clusterInsolators","bushInsolators"}) do
  58.     for _,insolator in ipairs(Peripherals[insolatorList]) do
  59.         local items = insolator.list()
  60.         for slot,item in pairs(items) do
  61.             if item.name == ItemNames.bush then
  62.                 insolator.pushItems(Peripherals.bushDrawer.name,slot)
  63.             elseif item.name == ItemNames.tallBush then
  64.                 insolator.pushItems(Peripherals.tallBushDrawer.name,slot)
  65.             elseif item.name == ItemNames.poiseBlock then
  66.                 insolator.pushItems(Peripherals.poiseBlockDrawer.name,slot)
  67.             elseif item.name == ItemNames.slime then
  68.                 insolator.pushItems(Peripherals.slimeDrawer.name,slot)
  69.             end
  70.         end
  71.     end
  72. end
  73. while true do
  74.     local tallBushCount = Peripherals.tallBushDrawer.getItemDetail(1).count
  75.     if tallBushCount > 1000 then
  76.         while Peripherals.tallBushDrawer.getItemDetail(1).count > 800 do
  77.             sleep(60)
  78.         end
  79.     end
  80.     term.clear()
  81.     term.setCursorPos(1,1)
  82.     print("handling tall bush insolators")
  83.     for _,insolator in ipairs(Peripherals.tallBushInsolators) do
  84.         Peripherals.tallBushDrawer.pushItems(insolator.name,1,math.ceil(tallBushCount / #Peripherals.tallBushInsolators),1)
  85.         local items = insolator.list()
  86.         for slot,item in pairs(items) do
  87.             if item.name == ItemNames.poiseBlock then
  88.                 insolator.pushItems(Peripherals.poiseBlockDrawer.name,slot,64)
  89.             end
  90.         end
  91.     end
  92.     local poiseBlockCount = Peripherals.poiseBlockDrawer.getItemDetail(1).count
  93.     term.clear()
  94.     term.setCursorPos(1,1)
  95.     print("handling poise cluster insolators")
  96.     for _,insolator in ipairs(Peripherals.clusterInsolators) do
  97.         Peripherals.poiseBlockDrawer.pushItems(insolator.name,1,math.ceil(poiseBlockCount / #Peripherals.clusterInsolators),1)
  98.         local items = insolator.list()
  99.         for slot,item in pairs(items) do
  100.             if item.name == ItemNames.bush then
  101.                 insolator.pushItems(Peripherals.bushDrawer.name,slot,64)
  102.             elseif item.name == ItemNames.slime then
  103.                 insolator.pushItems(Peripherals.slimeDrawer.name,slot,64)
  104.             end
  105.         end
  106.     end
  107.     local bushCount = Peripherals.bushDrawer.getItemDetail(1).count
  108.     term.clear()
  109.     term.setCursorPos(1,1)
  110.     print("handling bush insolators")
  111.     for _,insolator in ipairs(Peripherals.bushInsolators) do
  112.         Peripherals.bushDrawer.pushItems(insolator.name,1,math.ceil(bushCount / #Peripherals.bushInsolators),1)
  113.         local items = insolator.list()
  114.         for slot,item in pairs(items) do
  115.             if item.name == ItemNames.tallBush then
  116.                 insolator.pushItems(Peripherals.tallBushDrawer.name,slot,64)
  117.             elseif item.name == ItemNames.poiseBlock then
  118.                 insolator.pushItems(Peripherals.poiseBlockDrawer.name,slot,64)
  119.             end
  120.         end
  121.     end
  122. end
RAW Paste Data