插件我正在搜索聊天中的某些单词,然后将它们发送到指定的聊天帧,但它会随机发生错误并导致游戏崩溃
This application has encountered a critical error: ERROR #132 (0x85100084) Fatal Exception Program: C:\WoW\Wow.exe Exception: 0xC0000005 (ACCESS_VIOLATION) at 0023:00416DB0 The instruction at "0x00416DB0" referenced memory at "0x1F97FFFE". The memory could not be "read".
我打开cheatengine浏览该区域后,它崩溃了,看看那里有什么
1F97FFFE: http://i.imgur.com/D7XKi2D.jpg 00416DB0: http://i.imgur.com/duTM315.jpg
和插件代码:
--Event CHAT_MSG_CHANNEL if event == "CHAT_MSG_CHANNEL" then if TriggerEnabled then local arg1 = string.lower(arg1) local found, dump = false, false for k,v in pairs(lsus.Triggers) do if not found then for k,v in pairs(lsus.NegTriggers) do if (string.find(arg1, v)) then dump = true end end if (string.find(arg1, v)) and not dump then local output = " [\124Hplayer:" .. arg2 .. ":1:WHISPER\124h" .. arg2 .. "\124h\124r]: " .. arg1:gsub(v, "\124c0000FF00\124h" .. string.upper(v) .. "\124h\124r") print(output, 0.41, 0.80, 0.94) found = true end end end end end --print function function print(msg, r, g, b) if not r then ChatFrame1:AddMessage(msg) else ChatFrame1:AddMessage(msg, r, g, b) end end
任何人都可以帮我解释为什么这会让游戏崩溃吗?
答案 0 :(得分:0)
可能不是你的情况,但尝试使用string.find(arg1, v, 1, true)
而不是string.find(arg1, v)
来避免由于模式中的魔术字符而导致的意外行为。
-- Example:
local str = 'string.find hangs on this string'
string.find(str, '.*.*.*.*.*.*.*.*.*.*.*#')