Skip to content

Commit dfc7935

Browse files
authored
🪲 port ME Bridge bugfix from cyberbit/telem#96
1 parent 390a952 commit dfc7935

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎src/telem/modules/advancedPeripherals/MEBridgeInputAdapter.lua‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ return function (api)
88
function MEBridgeInputAdapter:beforeRegister (peripheralName, categories)
99
self.prefix = 'apmebridge:'
1010

11+
local _, component = next(self.components)
12+
local listCellsSupported = pcall(component.listCells) and true or false
13+
1114
self.queries = {
1215
basic = {
1316
energy_usage = fn():call('getEnergyUsage'):aeToFe():energyRate(),
1417
item_storage_used = fn():call('getUsedItemStorage'):with('unit', 'bytes'),
1518
fluid_storage_used = fn():call('getUsedFluidStorage'):with('unit', 'bytes'),
16-
cell_count = fn():call('listCells'):count(),
1719
},
1820
energy = {
1921
energy = fn():call('getEnergyStorage'):aeToFe():energy(),
@@ -27,6 +29,13 @@ return function (api)
2729
},
2830
}
2931

32+
if listCellsSupported then
33+
self.queries.basic.cell_count = fn():call('listCells'):count()
34+
else
35+
-- TODO debug logs aren't supported in adapter constructors yet
36+
self:dlog('MEBridgeInput:beforeRegister :: cell_count is not supported on this network, upgrade to Advanced Peripherals 0.7.41r or newer')
37+
end
38+
3039
-- TODO gas storage metrics?
3140

3241
-- getCraftingCPUs

0 commit comments

Comments
 (0)