Mebride compatibility fix
This commit is contained in:
+26
-6
@@ -26,7 +26,23 @@ local mf = require("morefonts-pe")
|
|||||||
|
|
||||||
local frame = Pine3D.newFrame()
|
local frame = Pine3D.newFrame()
|
||||||
frame:setBackgroundColor(colors.black)
|
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 chainItemsByBaseId
|
||||||
local baseItemIds
|
local baseItemIds
|
||||||
@@ -239,12 +255,14 @@ local function getItemIcon(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function getMeItemCount(itemId)
|
local function getMeItemCount(itemId)
|
||||||
if not meSystem or not itemId then
|
local bridge = ensureStorageBridge()
|
||||||
|
|
||||||
|
if not bridge or not itemId then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(meSystem.getItem) == "function" then
|
if type(bridge.getItem) == "function" then
|
||||||
local ok, item = pcall(meSystem.getItem, { name = itemId })
|
local ok, item = pcall(bridge.getItem, { name = itemId })
|
||||||
if ok and item then
|
if ok and item then
|
||||||
return tonumber(item.amount or item.count or item.qty) or 0
|
return tonumber(item.amount or item.count or item.qty) or 0
|
||||||
end
|
end
|
||||||
@@ -260,7 +278,9 @@ local function getMeItemCounts(itemIds)
|
|||||||
counts[itemIds[i]] = 0
|
counts[itemIds[i]] = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if not meSystem then
|
local bridge = ensureStorageBridge()
|
||||||
|
|
||||||
|
if not bridge then
|
||||||
return counts
|
return counts
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -282,7 +302,7 @@ local function getMeItemCounts(itemIds)
|
|||||||
return counts
|
return counts
|
||||||
end
|
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
|
if not listItems then
|
||||||
return counts
|
return counts
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user