移除多余消息分割函数

This commit is contained in:
尚美 2025-06-15 22:36:17 +08:00
parent 575a7c3490
commit 880a64d092
2 changed files with 41 additions and 42 deletions

View File

@ -358,22 +358,6 @@ function SM_Collections:ProcessItemsData()
end
end
-- 消息分割函数
function SM_Collections:MessageSplit(msg, delimiter)
local result = {}
local from = 1
local delim_from, delim_to = string.find(msg, delimiter, from)
while delim_from do
table.insert(result, string.sub(msg, from, delim_from - 1))
from = delim_to + 1
delim_from, delim_to = string.find(msg, delimiter, from)
end
table.insert(result, string.sub(msg, from))
return result
end
-- 处理收藏状态更新
function SM_Collections:HandleCollectionUpdate(msg)

View File

@ -1,17 +1,36 @@
-- SM_Utils.lua
function SM_Collections:MessageSplit(inputstr, sep)
if not inputstr or inputstr == "" then
return {}
-- function SM_Collections:MessageSplit(inputstr, sep)
-- print("分割1")
-- if not inputstr or inputstr == "" then
-- return {}
-- end
-- if sep == nil then
-- sep = "%s"
-- end
-- local t = {}
-- for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
-- table.insert(t, str)
-- end
-- return t
-- end
-- 消息分割函数
function SM_Collections:MessageSplit(msg, delimiter)
print("分割2")
local result = {}
local from = 1
local delim_from, delim_to = string.find(msg, delimiter, from)
while delim_from do
table.insert(result, string.sub(msg, from, delim_from - 1))
from = delim_to + 1
delim_from, delim_to = string.find(msg, delimiter, from)
end
if sep == nil then
sep = "%s"
end
local t = {}
for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
table.insert(t, str)
end
return t
table.insert(result, string.sub(msg, from))
return result
end
function SM_Collections:GetMountInfo(spellID)
@ -24,7 +43,7 @@ end
-- 坐骑技能ID到生物显示ID的映射表
SM_Collections.SpellToDisplayIDMap = {
-- 常见的坐骑技能ID映射
[65643] = 34554, -- 请用正确的显示ID替换这些示例值
[65643] = 34554, -- 请用正确的显示ID替换这些示例值
[65644] = 29256,
[65645] = 29257,
[66090] = 30358,
@ -34,13 +53,12 @@ SM_Collections.SpellToDisplayIDMap = {
function SM_Collections:GetCreatureDisplayID(itemID, itemType)
-- 检查itemID是否有效
if not itemID or type(itemID) ~= "number" or itemID <= 0 then
if itemType == "mount" then
return 16358 -- 返回默认坐骑ID
return 16358 -- 返回默认坐骑ID
elseif itemType == "companion" then
return 7380 -- 返回默认小伙伴ID
return 7380 -- 返回默认小伙伴ID
else
return 1 -- 返回默认ID
return 1 -- 返回默认ID
end
end
if itemType == "mount" then
@ -48,33 +66,31 @@ function SM_Collections:GetCreatureDisplayID(itemID, itemType)
if SM_Collections.SpellToDisplayIDMap and SM_Collections.SpellToDisplayIDMap[itemID] then
local mountData = SM_Collections.SpellToDisplayIDMap[itemID]
if mountData.effectMiscValue then
return mountData.effectMiscValue
end
end
-- 再尝试使用本地映射表
local mountInfo = self:GetMountInfo(itemID)
if mountInfo then
return mountInfo -- 第一个返回值就是 creatureDisplayID
end
-- 如果本地映射表中没有,提示错误
return 16358 -- 返回一个默认模型ID避免显示错误
return 16358 -- 返回一个默认模型ID避免显示错误
elseif itemType == "companion" then
-- 使用Companions.lua中的数据
if SM_Collections.Companions and SM_Collections.Companions[itemID] then
local companionData = SM_Collections.Companions[itemID]
if companionData.effectMiscValue then
return companionData.effectMiscValue
end
end
-- 如果上面的方法失败返回默认ID
return 7380 -- 默认小伙伴ID
return 7380 -- 默认小伙伴ID
elseif itemType == "card" then
local cardMap = {
[26502] = 26502, -- 拉格纳罗斯
@ -86,4 +102,3 @@ function SM_Collections:GetCreatureDisplayID(itemID, itemType)
end
return itemID
end