Mebride compatibility fix

This commit is contained in:
Max
2026-06-01 14:57:40 +02:00
parent 63775ae3ea
commit 0c33acf06d
+26 -6
View File
@@ -26,7 +26,23 @@ local mf = require("morefonts-pe")
local frame = Pine3D.newFrame()
frame:setBackgroundColor(colors.black)
local meSystem = peripheral.find("meBridge") or peripheral.find("rsBridge")
local function findStorageBridge()
return peripheral.find("meBridge")
or peripheral.find("me_bridge")
or peripheral.find("rsBridge")
or peripheral.find("rs_bridge")
end
local meSystem = findStorageBridge()
local function ensureStorageBridge()
if not meSystem then
meSystem = findStorageBridge()
end
return meSystem
end
local chainItemsByBaseId
local baseItemIds
@@ -239,12 +255,14 @@ local function getItemIcon(item)
end
local function getMeItemCount(itemId)
if not meSystem or not itemId then
local bridge = ensureStorageBridge()
if not bridge or not itemId then
return 0
end
if type(meSystem.getItem) == "function" then
local ok, item = pcall(meSystem.getItem, { name = itemId })
if type(bridge.getItem) == "function" then
local ok, item = pcall(bridge.getItem, { name = itemId })
if ok and item then
return tonumber(item.amount or item.count or item.qty) or 0
end
@@ -260,7 +278,9 @@ local function getMeItemCounts(itemIds)
counts[itemIds[i]] = 0
end
if not meSystem then
local bridge = ensureStorageBridge()
if not bridge then
return counts
end
@@ -282,7 +302,7 @@ local function getMeItemCounts(itemIds)
return counts
end
local listItems = meSystem.listItems or meSystem.getItems or meSystem.listAvailableItems
local listItems = bridge.listItems or bridge.getItems or bridge.listAvailableItems
if not listItems then
return counts
end