Hello there,
I'm working on a small addon for personal use to remove the very annoying [Fansoz-Dragonblight] into [Fansoz] (like it was prior to 5.4.2).
I am, however, getting stuck at figuring out how to ensure it catches "-Realmname".
Here is my current code in it's enterity:
Code:
function huFilter(self, event, msg)
local removestring = "-"..GetRealmName()
if msg:find(removestring) then
return string.gsub(msg, removestring, "")
end
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", huFilter)
ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", huFilter)
ChatFrame_AddMessageEventFilter("CHAT_MSG_YELL", huFilter)
ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", huFilter)
When writing, for example, -Dragonblight in the /s it does remove the line, the whole thing. Nothing's shown instead of all but the "-Dragonblight" part.
I'm not very novice in terms of programming, but I'm not used to event based programming and lua/wow api. So, I don't want a complete answer since I really want to learn this stuff too, so a resource or an explanation of what I'm doing wrong is really all I'm asking for.
Also I am curious to learn more about the msg:find functionality, I was told by a similarily novice as myself it was useful, personal I'm pondering the usefulness of it since the gsub should simply return a nil value if there's no matches found, right?
Thanks!
/Fansoz (Best disco eu! )