-- 显示物品需求
if GUI:Win_IsNotNull(ui.itemroom) and next_data then
GUI:removeAllChildren(ui.itemroom)
local item_name = next_data.name2 or "称号卷轴"
local itemCount = tonumber(SL:GetMetaValue("ITEM_COUNT", item_name)) o
```lua
-- 判断是否为手机端
local isMobile = SL:GetMetaValue("IS_MOBILE", 0) or 0
-- 显示物品需求
if GUI:Win_IsNull(ui.itemroom) == false and next_data then
GUI:removeAllChildren(ui.itemroom)
local item_name = next_data.name2 or "称号卷轴"
local itemCount = tonumber(SL:GetMetaValue("ITEM_COUNT", item_name)) or 0
local needItemCount = tonumber(next_data.value2) or 0
-- 金币检查
local goldCount = tonumber(SL:GetMetaValue("MONEY", 1)) or 0
local needGold = tonumber(next_data.value1) or 0
-- 获取物品ID
local item_id = 0
if next_data.itemid then
item_id = tonumber(next_data.itemid) or 12453
else
-- 自定义函数:lib:getitemidx 需要你自己实现或查找底层函数
item_id = lib:getitemidx(item_name) or 12453
end
-- 获取货币ID
local money_id = tonumber(next_data.moneyid) or 1
-- 安全比较函数
local function safe_lt(a, b)
local num_a = tonumber(a) or 0
local num_b = tonumber(b) or 0
return num_a < num_b
end
-- 根据是否足够设置颜色
local itemColor = 255
if safe_lt(itemCount, needItemCount) then
itemColor = 58
end
local goldColor = 255
if safe_lt(goldCount, needGold) then
goldColor = 58
end
-- 根据平台设置坐标
local goldX, goldY = 53, 90
local itemX, itemY = 140, 90
if isMobile == 1 then
-- 手机端坐标调整
goldX, goldY = 40, 100
itemX, itemY = 120, 100
end
-- 创建金币显示
GUI:ItemShow_Create(ui.itemroom, "ItemShow_1", goldX, goldY, {
index = money_id,
count = needGold,
look = true,
bgVisible = false,
color = goldColor
})
-- 创建称号卷轴显示
GUI:ItemShow_Create(ui.itemroom, "ItemShow_2", itemX, itemY, {
index = item_id,
count = needItemCount,
look = true,
bgVisible = false,
color = itemColor
})
end
```
**说明:**
1. 使用 `SL:GetMetaValue("IS_MOBILE", 0)` 获取是否为手机端(1=手机,0=PC)
2. 根据 `isMobile` 值调整两个ItemShow的坐标
3. `lib:getitemidx()` 是自定义函数,需要你根据实际需求实现物品名称转ID的功能
4. 颜色值58表示红色(不足),255表示正常颜色
5. 手机端坐标做了适当调整,你可以根据实际UI布局修改具体数值