System Message Parsing - WoWInterface
Thread Tools Display Modes
10-18-06, 10:50 AM   #1
A Kobold Labourer
Join Date: Oct 2006
Posts: 1
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.

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.
  Reply With Quote
11-25-06, 08:26 AM   #2
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 2
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)

Last edited by OnmyojiOmn : 11-25-06 at 08:29 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » System Message Parsing

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off