function ItemTips.ParseExAddAttr(attr, needAttrList)
if not attr or string.len(attr) == "" then
return
end
local attrAlignment = SL:GetMetaValue("WINPLAYMODE") and tonumber(SL:GetMetaValue("GAME_DATA", "pc_tips_attr_alignment
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-04-14 13:31:50 |
👁️ 阅读: 9
根据浮生梦老师前端课程内容,要让特定装备在只有一个附加属性时显示`[鉴定品级·梦归]:`,可以在判断装备特定条件后覆盖`titleName`和`titleColor`。以下是修改后的代码片段:
```lua
function ItemTips.ParseExAddAttr(attr, needAttrList)
-- ... 前面的代码保持不变 ...
local strList = {}
if attrShow and next(attrShow) then
local count = 0
for k, v in pairs(attrShow) do
count = count + 1
end
local titleName = ItemTips._showTitleList[3] and ItemTips._showTitleList[3].name or "[鉴定属性]:"
local titleColor = ItemTips._showTitleList[3] and ItemTips._showTitleList[3].color or 243
-- 根据属性数量设置标题
if count == 1 then
titleName = "[鉴定品级·精良]:"
titleColor = 250
elseif count == 2 then
titleName = "[鉴定品级·稀有]:"
titleColor = 154
elseif count == 3 then
titleName = "[鉴定品级·史诗]:"
titleColor = 253
elseif count == 4 then
titleName = "[鉴定品级·断尘]:"
titleColor = 151
elseif count == 5 then
titleName = "[鉴定品级·执月]:"
titleColor = 243
elseif count == 6 then
titleName = "[鉴定品级·梦归]:"
titleColor = 249
end
-- 特定装备处理:只有一个附加属性时显示梦归级别
-- 假设通过itemData参数判断特定装备,这里需要itemData参数传入
-- 如果itemData不存在,可以从外部传入或通过其他方式获取
if count == 1 and itemData and itemData.StdMode == 特定装备类型 then
titleName = "[鉴定品级·梦归]:"
titleColor = 249
end
local titleStr = string.format("<font color='%s'>%s</font>", SL:GetHexColorByStyleId(titleColor), titleName)
table.insert(strList, {
str = titleStr
})
-- ... 后面的代码保持不变 ...
end
return strList
end
```
注意:你需要:
1. 将`itemData`参数添加到函数定义中:`function ItemTips.ParseExAddAttr(attr, needAttrList, itemData)`
2. 在调用此函数时传入装备数据
3. 将`特定装备类型`替换为实际的装备类型ID(如53表示镇派宝典)
这样特定装备即使只有一个附加属性,也会显示为梦归级别。
根据浮生梦老师前端课程内容,要让特定装备在只有一个附加属性时显示`[鉴定品级·梦归]:`,可以在判断装备特定条件后覆盖`titleName`和`titleColor`。以下是修改后的代码片段:
```lua
function ItemTips.ParseExAddAttr(attr, needAttrList)
-- ... 前面的代码保持不变 ...
local strList = {}
if attrShow and next(attrShow) then
local count = 0
for k, v in pairs(attrShow) do
count = count + 1
end
local titleName = ItemTips._showTitleList[3] and ItemTips._showTitleList[3].name or "[鉴定属性]:"
local titleColor = ItemTips._showTitleList[3] and ItemTips._showTitleList[3].color or 243
-- 根据属性数量设置标题
if count == 1 then
titleName = "[鉴定品级·精良]:"
titleColor = 250
elseif count == 2 then
titleName = "[鉴定品级·稀有]:"
titleColor = 154
elseif count == 3 then
titleName = "[鉴定品级·史诗]:"
titleColor = 253
elseif count == 4 then
titleName = "[鉴定品级·断尘]:"
titleColor = 151
elseif count == 5 then
titleName = "[鉴定品级·执月]:"
titleColor = 243
elseif count == 6 then
titleName = "[鉴定品级·梦归]:"
titleColor = 249
end
-- 特定装备处理:只有一个附加属性时显示梦归级别
-- 假设通过itemData参数判断特定装备,这里需要itemData参数传入
-- 如果itemData不存在,可以从外部传入或通过其他方式获取
if count == 1 and itemData and itemData.StdMode == 特定装备类型 then
titleName = "[鉴定品级·梦归]:"
titleColor = 249
end
local titleStr = string.format("<font color='%s'>%s</font>", SL:GetHexColorByStyleId(titleColor), titleName)
table.insert(strList, {
str = titleStr
})
-- ... 后面的代码保持不变 ...
end
return strList
end
```
注意:你需要:
1. 将`itemData`参数添加到函数定义中:`function ItemTips.ParseExAddAttr(attr, needAttrList, itemData)`
2. 在调用此函数时传入装备数据
3. 将`特定装备类型`替换为实际的装备类型ID(如53表示镇派宝典)
这样特定装备即使只有一个附加属性,也会显示为梦归级别。
← 返回问答库