WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   System Message Parsing (https://www.wowinterface.com/forums/showthread.php?t=6585)

Zarah 10-18-06 10:50 AM

System Message Parsing
 
I apologize if this has been answered else where but I have been unable to find what I am looking for.

I am looking to parse the name of the player (PlayerX) in each of the following system messages.

PlayerX is already in a group.
PlayerX declines your group invitation.
PlayerX joins the party.
PlayerX has joined the raid group
Cannot find 'PlayerX'.

I have some hacked together code that will do this below that I have taken from another mod. It takes the entire string from CHAT_MSG_SYSTEM and looks for the space in the first 4 cases or the ' in the last one and sends me back just the name.

Code:

function RN_GetArgs(message, separator)
        -- This procedure from DKP_System by Sammysnake
        -- Declare 'args' variable.
        local args = {};

        -- Declare 'i' integer.
        i = 0;

        -- Search for seperators in the string and return
        -- the separated data.
        for value in string.gfind(message, "[^"..separator.."]+") do
                i = i + 1;
                args[i] = value;
        end -- end for

        -- Submit the filtered data.
        return args;
end -- end RN_GetArgs()

Does Blizzard provide this information already in an arg that I am missing? Is there another/better Event that I could be looking at? Or is this the best way to obtain this information?

Any information greatly appreciated as this is my first shot at a 'real' mod.

OnmyojiOmn 11-25-06 08:26 AM

If you take a look in FrameXML\GlobalStrings.lua, you'll find all of the game's localized format strings. You use the provided format string to create a pattern, which is used to parse the message. The awesome thing about this is that it's localized, so your mod will work overseas barring other problems.

local pattern = string.format(ERR_ALREADY_IN_GROUP_S, "(%a+)")
local startIndex, endIndex, characterName = string.find(arg1, pattern)


All times are GMT -6. The time now is 09:14 PM.

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