魔兽世界中的lua代码问题
上述情况导致魔兽世界无法加载到游戏中。因为我缺乏程序本身的调试能力,有人知道为什么吗 以下是上述代码中提到的其他功能:魔兽世界中的lua代码问题,lua,world-of-warcraft,Lua,World Of Warcraft,上述情况导致魔兽世界无法加载到游戏中。因为我缺乏程序本身的调试能力,有人知道为什么吗 以下是上述代码中提到的其他功能: -- Color Nicks if CM2_Options["ColorNicks"] then -- Hold Original unmodified words for later use local temp2 = ChatMod2_GetWords(text) local temp = ChatMod2_StripSpecial(text
-- Color Nicks
if CM2_Options["ColorNicks"] then
-- Hold Original unmodified words for later use
local temp2 = ChatMod2_GetWords(text)
local temp = ChatMod2_StripSpecial(text)
temp = string.gsub(temp, "[^a-zA-Z0-9%s]", "")
temp = temp:lower()
local words = ChatMod2_GetWords(temp)
for word = 1, #words do
-- Cant be the player name or it locks up the client... Go figure...
if words[word] ~= UnitName("player") then
print(temp)
if CM2_Nick[words[word]] ~= nil then
--{level, class, guild, realm, name} Nick Layout. Name is the unfiltered name.
local newWord = ChatMod2_ColorName(CM2_Nick[words[word]][2], words[word])
text = text:gsub(temp2[word], newWord)
end
end
end
end
函数ChatMod2_GetWords(str)
局部结果={}
对于string.gmatch(str,“%S+”,9)中的单词
表.插入(结果,word)
结束
返回结果
结束
函数ChatMod2_ColorName(str,word)
--使用提供的类和单词为聊天预先着色。
如果str==“MONK”,那么
word=“\124cff00ff96”。。尼克[字][5]。。“| r”
elseif str==“死亡骑士”然后
word=“\124cffc41f3b”。。尼克[字][5]。。“| r”
elseif str==“德鲁伊”然后
word=“\124cffff7d0a”。。尼克[字][5]。。“| r”
elseif str==“猎人”然后
word=“\124cffabd473”。。尼克[字][5]。。“| r”
elseif str==“MAGE”然后
word=“\124cff69ccf0”。。尼克[字][5]。。“| r”
elseif str==“圣骑士”然后
word=“\124cfff58cba”。。尼克[字][5]。。“| r”
elseif str==“牧师”然后
word=“\124cffffffff”。。尼克[字][5]。。“| r”
elseif str==“流氓”然后
word=“\124cfffff569”。。尼克[字][5]。。“| r”
elseif str==“萨满”然后
word=“\124cff0070de”。。尼克[字][5]。。“| r”
elseif str==“术士”然后
word=“\124cff9482c9”。。尼克[字][5]。。“| r”
elseif str==“战士”然后
word=“\124cffc79c6e”。。尼克[字][5]。。“| r”
结束
回信
结束
函数ChatMod2_条带特殊(msg)
--去掉所有特殊字符,如Ö等。
--应仅用于返回临时字符串,除非需要替换。
如果msg~=nil并键入(msg)=“字符串”,则
对于x=1,#msg do
local CharVal=string.byte(string.sub(msg,x,x+1),-1)
--本地StrTab={}
--对于a=1,#msg do
--StrTab:插入(
--打印(“调试:…string.byte(string.sub(msg,x,x+1)))
--打印(CharVal)
如果CharVal~=nil,则
如果146
ChatMod2\u GetWords
显然没有问题
另一方面,ChatMod2\u ColorName
如果CM2\u Nick
没有单词条目或该条目没有索引5,则会爆炸
我还没有看太多的
ChatMod2\u stripsecial
。引用的函数是否正常工作?第一个代码片段中的代码是否是导致游戏无法启动的新代码?是的,我已经在客户端通过/运行对它们进行了测试,它们按照预期工作。上次发生这种情况时,它是一个无限长的loop,但我看不出你运行引用函数的准确程度如何?什么参数?什么全局状态?ChatMod2\u GetWords
显然很好。ChatMod2\u ColorName
另一方面,如果CM2\u Nick
没有word
条目,或者该条目没有索引5
,就会爆炸。我还没看过在ChatMod2_StripSpecial上还有很多。是的,Idk…我在WoWLua中使用了一些代码,并通过修复名称引用在那里修复了它,我认为这也与此有关。将其作为答案发布,我会接受它。我对它的处理方式进行了修改,它似乎正在工作,所以我打赌这就是问题所在。我不是确定官方对此的政策是什么,但发布您实际所做的更改(在评论中或作为对您问题的编辑)可能是个好主意。我将于明天发布。时间已晚,我目前无法访问。正在工作但即将完成的版本的代码粘贴在此处:
function ChatMod2_GetWords(str)
local results = {}
for word in string.gmatch(str, "%S+", 9) do
table.insert(results, word)
end
return results
end
function ChatMod2_ColorName(str, word)
--Using the class and word provided precolor it for chat.
if str == "MONK" then
word = "\124cff00ff96" .. CM2_Nick[word][5] .. "|r"
elseif str == "DEATH KNIGHT" then
word = "\124cffc41f3b" .. CM2_Nick[word][5] .. "|r"
elseif str == "DRUID" then
word = "\124cffff7d0a" .. CM2_Nick[word][5] .. "|r"
elseif str == "HUNTER" then
word = "\124cffabd473" .. CM2_Nick[word][5] .. "|r"
elseif str == "MAGE" then
word = "\124cff69ccf0" .. CM2_Nick[word][5] .. "|r"
elseif str == "PALADIN" then
word = "\124cfff58cba" .. CM2_Nick[word][5] .. "|r"
elseif str == "PRIEST" then
word = "\124cffffffff" .. CM2_Nick[word][5] .. "|r"
elseif str == "ROGUE" then
word = "\124cfffff569" .. CM2_Nick[word][5] .. "|r"
elseif str == "SHAMAN" then
word = "\124cff0070de" .. CM2_Nick[word][5] .. "|r"
elseif str == "WARLOCK" then
word = "\124cff9482c9" .. CM2_Nick[word][5] .. "|r"
elseif str == "WARRIOR" then
word = "\124cffc79c6e" .. CM2_Nick[word][5] .. "|r"
end
return word
end
function ChatMod2_StripSpecial(msg)
--Strips out all special characters such as Ö and the like.
--Should only be used for being returned to a temp string unless replacement is required.
if msg ~= nil and type(msg) == "string" then
for x=1, #msg do
local CharVal = string.byte(string.sub(msg,x,x+1), -1)
--local StrTab = {}
--for a=1, #msg do
-- StrTab:Insert(
--print("Debug: "..string.byte(string.sub(msg,x,x+1)))
--print(CharVal)
if CharVal ~= nil then
if 146 <= CharVal and CharVal <= 150 then
msg = StringReplace(msg, x, "O")
elseif 178 <= CharVal and CharVal <= 182 then
msg = StringReplace(msg, x, "o")
elseif 128 <= CharVal and CharVal <= 134 then
msg = StringReplace(msg, x, "A")
elseif 160 <= CharVal and CharVal <= 166 then
msg = StringReplace(msg, x, "a")
elseif 136 <= CharVal and CharVal <= 139 then
msg = StringReplace(msg, x, "E")
elseif 168 <= CharVal and CharVal <= 171 then
msg = StringReplace(msg, x, "e")
elseif 153 <= CharVal and CharVal <= 156 then
msg = StringReplace(msg, x, "U")
elseif 185 <= CharVal and CharVal <= 188 then
msg = StringReplace(msg, x, "u")
elseif 140 <= CharVal and CharVal <= 143 then
msg = StringReplace(msg, x, "I")
elseif 172 <= CharVal and CharVal <= 175 then
msg = StringReplace(msg, x, "i")
elseif 135 == CharVal then
msg = StringReplace(msg, x, "C")
elseif 167 == CharVal then
msg = StringReplace(msg, x, "c")
elseif 144 == CharVal then
msg = StringReplace(msg, x, "D")
elseif 176 == CharVal then
msg = StringReplace(msg, x, "o")
elseif 152 == CharVal then
msg = StringReplace(msg, x, "O")
elseif 184 == CharVal then
msg = StringReplace(msg, x, "o")
end
end
end
end
return msg
end