|
||||||
| AddOn HELP! Requests for assistance and misc bug reports go here. | ||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Junior Member
Join Date: Oct 2008
Posts: 71
|
I've finally done some digging and have found out that something very different is happening with the way that an event is being triggered though Rawhook.
I've borrowed this code from Forumname2 and cut it down so you can see what's going on: Code:
ForumName2 = LibStub("AceAddon-3.0"):NewAddon("ForumName2", "AceHook-3.0", "AceEvent-3.0", "AceConsole-3.0")
local string_gsub, string_format, string_match, string_lower, table_insert, table_wipe = string.gsub, string.format, string.match, string.lower, tinsert, wipe
local defaults = {
profile = {
customNotes = {},
}
}
local chatEvents = {
["CHAT_MSG_CHANNEL"] = true,
["CHAT_MSG_SAY"] = true,
["CHAT_MSG_YELL"] = true,
}
local selectedName, unitName, note
function ForumName2:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("ForumNameDB", defaults, true)
end
function ForumName2:OnEnable()
self.db.profile.customNotes = {
["Kaziopoeia"] = "Kaztest",
}
for i = 1, NUM_CHAT_WINDOWS do
self:RawHook(_G["ChatFrame" .. i], "AddMessage", "AddMessage", true)
end
end
function ForumName2:AddMessage(frame, msg, ...)
if(chatEvents[event]) then
local note = self.db.profile.customNotes[arg2]
if note then
msg = string_gsub(msg, "|h(.*)" .. arg2 .. "(.*)|h", "|h%1" .. arg2 .. " (gimp)" .. "%2|h", 1)
self:Print(note.." found for "..arg2)
else
msg = string_gsub(msg, "|h(.*)" .. arg2 .. "(.*)|h", "|h%1" .. arg2 .. " (no gimp)" .. "%2|h", 1)
end
else
-- msg = msg..tostring(event)
msg = msg.." "..tostring(arg2)
end
self.hooks[frame]["AddMessage"](frame, msg, ...)
end
this USED to work passing events and args through to this function, however now, both event and arg are NIL. Any idea what changed and how I can fix it. I'm 99% sure that this problem affects Spamthrottle also Thanks loads Kaz It's probably helpful to explain what I'm trying to do here.. If it's a non listed event then arg2 should be added to the end of the message (If i replace it with msg = msg.." test" then it successfully appends test... currently it sticks NIL at the end) if the event turns out to be one of the listed ones then it will add a title (or gimp) as desired. The whole code used to work perfectly, it's just the hook that's no longer passing through the event or the arguments thereof Last edited by DrKazza; 10-16-2010 at 09:13 AM. |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Dec 2009
Posts: 1
|
Looks like you're using arg1, arg2, etc. as globals in your orumName2:AddMessage() event handler. You need to change to new syntax. A quick fix should be this:
function ForumName2:AddMessage(frame, msg, ...) local arg1, arg2 = ...; if(chatEvents[event]) then local note = self.db.profile.customNotes[arg2] ...etc... This is according to this helpful forum post: http://forums.worldofwarcraft.com/th...Id=25626580975 But also useful to me was the info in the following: http://www.wowwiki.com/API_ChatFrame...ageEventFilter Especially the first example filter implementation. Note that I am by NO means an expert here, but I was able to get SpamThrottle back up and seemingly working. It should be approved shortly, so feel free to have a look in the updated code there when it appears. Good luck! ![]() -- Orukxu |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2008
Posts: 71
|
you rock dude, looks like the arg things will work fine... just need to work out how to get the event to feed though
Last edited by DrKazza; 10-16-2010 at 12:28 PM. |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Oct 2008
Posts: 71
|
Nah, no joy... I'll have to spend some time actually learning about hooks and registering events rather than just dragging and dropping code.
Thanks for the help anyway |
|
|
|
|
|
#5 |
|
Seal Cub Clubbing Club
Join Date: May 2005
Location: California, US
Posts: 7,758
|
If you're trying to modify messages being added to the chat frame, you should be using the chat filtering API that was added way back in patch 2.4, instead of trying to hook AddMessage.
http://www.wowwiki.com/API_ChatFrame...ageEventFilter http://www.wowwiki.com/API_ChatFrame...ageEventFilter
__________________
& Author/maintainer of Grid, PhanxChat, and many more. | PM me on CurseForge Troubleshoot an addon | Turn any code into an addon | More addon resources Need help with your code? Attach or paste your whole, real files. Please don't PM me about addon bugs, requests, or code help. Post a comment, ticket, or thread instead! |
|
|
|
|
|
#6 |
|
Amazing Member
Join Date: Feb 2005
Posts: 1,076
|
The filters don't allow you to do as many rewrites as what AddMessage does. I haven't looked at the OP's code, but if he's trying to do anything to (for example) the [Name_Of_Channel] or [Name_Of_Player] tags, hooking AddMessage is required.
|
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Oct 2008
Posts: 71
|
Thanks guys... I had a peek and saw that this was a much better way of handling the code.
Seems that Forumname was written a long time ago and if re-written today would use that. My addon's now fixed Thanks loads for the help. |
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
All times are GMT. The time now is 04:39 AM.
WowAce Forums





