WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   pattern matching (https://www.wowinterface.com/forums/showthread.php?t=48291)

Rilgamon 10-12-13 06:02 AM

They do, when you add the global string of the message ("You are now queued in the Raid Finder.") to your pattern list.

from GlobalStrings.lua
Lua Code:
  1. ERR_LFG_JOINED_RF_QUEUE = "You are now queued in the Raid Finder.";

Caellian 10-12-13 06:19 AM

Quote:

Originally Posted by Rilgamon (Post 285784)
They do, when you add the global string of the message ("You are now queued in the Raid Finder.") to your pattern list.

from GlobalStrings.lua
Lua Code:
  1. ERR_LFG_JOINED_RF_QUEUE = "You are now queued in the Raid Finder.";

You're missunderstanding, that's not at all what i'm trying to filter, i'm guessing that one was taken because it has "now" in it, since my catch wasn't specific enough.

This is what i want to filter, but those just aren't:

Code:

ROLE_CHANGED_INFORM = "%s is now %s.";
ROLE_CHANGED_INFORM_WITH_SOURCE = "%s is now %s. (Changed by %s.)";


Lombra 10-12-13 06:41 AM

Quote:

Originally Posted by Caellian (Post 285780)
That's the part i don't get, since it has nothing to do with it.

Code:

MESSAGE: You are now queued in the Raid Finder. 0
Also, well i'm not sure yet, but it looks like it only doesn't work in battlegrounds, nothing gets printed at all.

Hard to tell for now. Doesn't make much sense tbh.

Is that what your addon prints when in your chat frame you see "[Player] is now [role]." or what are you saying?

Move the print(message) to outside of the if-block and see what it says when someone sets their role.



EDIT: Ok ok, it's not even a chat event, hah. :P
Code:

ROLE_CHANGED_INFORM(changed, from, oldRole, newRole)
You can probably just do this to remove these messages:
Code:

RoleChangedFrame:UnregisterEvent("ROLE_CHANGED_INFORM")
Now that I think of it, I seem to recall this from some other thread...

Rilgamon 10-12-13 07:07 AM

Ups, did not expect that ... for the records:

http://wowprogramming.com/utils/xmlb...L/RolePoll.xml
Code:

    <Frame name="RoleChangedFrame" parent="UIParent">
        <Scripts>
            <OnLoad function="RoleChangedFrame_OnLoad"/>
            <OnEvent function="RoleChangedFrame_OnEvent"/>
        </Scripts>
    </Frame>

http://wowprogramming.com/utils/xmlb...L/RolePoll.lua

Lua Code:
  1. function RoleChangedFrame_OnLoad(self)
  2.     self:RegisterEvent("ROLE_CHANGED_INFORM");
  3. end
  4.  
  5. function RoleChangedFrame_OnEvent(self, event, ...)
  6.     if ( event == "ROLE_CHANGED_INFORM" ) then
  7.         local changed, from, oldRole, newRole = ...;
  8.          
  9.         if ( newRole == "NONE" ) then
  10.             if ( changed == from ) then
  11.                 ChatFrame_DisplaySystemMessageInPrimary(format(ROLE_REMOVED_INFORM, changed));
  12.             else
  13.                 ChatFrame_DisplaySystemMessageInPrimary(format(ROLE_REMOVED_INFORM_WITH_SOURCE, changed, from));
  14.             end
  15.         else
  16.             local displayedRole = _G["INLINE_"..newRole.."_ICON"].." ".._G[newRole];    --Uses INLINE_TANK_ICON, etc.
  17.             if ( changed == from ) then
  18.                 ChatFrame_DisplaySystemMessageInPrimary(format(ROLE_CHANGED_INFORM, changed, displayedRole));
  19.             else
  20.                 ChatFrame_DisplaySystemMessageInPrimary(format(ROLE_CHANGED_INFORM_WITH_SOURCE, changed, displayedRole, from));
  21.             end
  22.         end
  23.     end
  24. end

Caellian 10-12-13 07:41 AM

Sure these are events, but as you can see, there's something sent to chat "ChatFrame_DisplaySystemMessageInPrimary"

There's no need to unregister the event, there has to be a way to just filter the message, right ?

And the question is, why aren't the patterns catching them ?

Lombra 10-12-13 07:52 AM

Quote:

Originally Posted by Caellian (Post 285790)
Sure these are events, but as you can see, there's something sent to chat "ChatFrame_DisplaySystemMessageInPrimary"

There's no need to unregister the event, there has to be a way to just filter the message, right ?

Sure, you can override ChatFrame1.AddMessage and filter it out that way. Wouldn't recommend it, though. If your only mission is to suppress these messages, then unregister that event. The only purpose of RoleChangedFrame is to print out those messages, as far as I can tell. There's no reason to look for another way.

Quote:

Originally Posted by Caellian (Post 285790)
And the question is, why aren't the patterns catching them ?

Because they aren't chat events. The chat filtering system doesn't work on any event, only CHAT_MSG_* events. Edit: To answer the exact question; because those messages never reach that pattern test. The pattern is fine.

Caellian 10-12-13 09:17 AM

Code:

RoleChangedFrame:UnregisterAllEvents()
Works, obviously.

But it bothers me. Why the filtering way wouldn't work. I mean, those messages are sent to CHAT_MSG_SYSTEM right ?

So, if they are why can't i filter them there like just about anything else being sent to the chat ?

Lombra 10-12-13 10:17 AM

Quote:

Originally Posted by Caellian (Post 285790)
But it bothers me. Why the filtering way wouldn't work. I mean, those messages are sent to CHAT_MSG_SYSTEM right ?

They are not. CHAT_MSG_SYSTEM is a real event. Nothing is "sent to" being a chat event. When I say chat event I just mean the events that are handled by the chat frame. In this case the event is ROLE_CHANGED_INFORM, nothing else.

Caellian 10-12-13 10:20 AM

Quote:

Originally Posted by Lombra (Post 285796)
They are not.

ChatFrame_DisplaySystemMessageInPrimary ?

Or not, i don't know :)

Phanx 10-13-13 02:39 AM

Quote:

Originally Posted by Caellian (Post 285764)
Thing is, with this, absolutely nothing gets printed. How can that be ?

It should only print something when a role changed message appears. If you're not playing in an English client, you'll need to change the " is now " search string to the appropriate text to match in your language.

Also, you may want to change the last line in topattern to escape all the "magic characters", not just parentheses. For my purposes it didn't matter, but if you're using it on other global strings, it might matter.

Code:

text = gsub(text, "([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1")

Caellian 10-13-13 03:32 AM

Quote:

Originally Posted by Phanx (Post 285811)
It should only print something when a role changed message appears. If you're not playing in an English client, you'll need to change the " is now " search string to the appropriate text to match in your language.

That's the thing, i am on an enGB client, playing on a frFR realm but that doesn't make any difference and the " is now " didn't catch anything.

Quote:

Originally Posted by Phanx (Post 285811)
Also, you may want to change the last line in topattern to escape all the "magic characters", not just parentheses. For my purposes it didn't matter, but if you're using it on other global strings, it might matter.

Code:

text = gsub(text, "([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1")

Done, i'll try again like this though i didn't notice any other special characters other than the (Changed by...)

Caellian 10-16-13 08:53 AM

Quote:

Originally Posted by Phanx (Post 285811)
Code:

text = gsub(text, "([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1")

Phanx, this new line doesn't work when for example, switching between 2 specs on a hunter, "Your pet has unlearned..."


All times are GMT -6. The time now is 11:39 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI