Thread Tools Display Modes
10-21-07, 05:38 PM   #1
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
Targets name from combat log

Whats the easiest way to pull your target's full name from the combat log?

if i have: "Timber Worg is afflicted by Spell Vulnerability"

and I do:
Code:
function myString_findPattern(text, pattern, start)
   return string.sub(text, string.find(text, pattern, start))
end

local targetName = myString_findPattern(arg1, "%a*")
Then I get:

targetName = "Timber"

not "Timber Worg" and I need to know how to call the whole name
  Reply With Quote
10-21-07, 09:24 PM   #2
Eidolarr
An Aku'mai Servant
 
Eidolarr's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 34
Ok. The problem is that the pattern you search for, %a+, doesn't account for whitespace, so it hits the first unit of whitespace and stops.

Easiest way? Find a library that does it for you. :P
  Reply With Quote
10-21-07, 10:31 PM   #3
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
SCT seems to call ..target.. for when it references a targets name but I can't seem to locate what library its in...does anyone know? or could you point me to a library that shows how thats referenced?
  Reply With Quote
10-21-07, 11:57 PM   #4
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
If still referencing Timber Worg is afflicted by Spell Vulnerability

I figured out that by adding %s%a* into my code below:
Code:
function myString_findPattern(text, pattern, start)
   return string.sub(text, string.find(text, pattern, start))
end

local targetName = myString_findPattern(arg1, "%a*%s%a*")
...I can now include the "white space" and the next word, returning "Timber Worg" for example.

This brings about a different situation. The new code returns two words...indifferent if its the targets name or not. So when a player target's name is referenced, instead of "Timber Worg," after this change has been made, it would make targetname = "You are" or "Soandso is" for example (because it pulls the first two words).

So if i were attacking Majordomo Executus it would return his full name
If I were attacking another player, it would return "Soandso is"
and if I were attacking Wing Commander Duffy, it would just return "Wing Commander"
  Reply With Quote
10-22-07, 09:23 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
The library sct uses is ParserLib. Take your pick of which version to use....
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Targets name from combat log

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