View Single Post
03-31-14, 11:47 AM   #27
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Clamsoda View Post
Lua Code:
  1. -- originalName is defined is this fashion as an example; in practice
  2. -- you will want to pass whatever variable contains the NAME-REALM key
  3. -- into strsplit().
  4. local originalName = "Clamsoda-BleedingHollow"
  5. local unitName, unitRealm = strsplit("-", originalName)
  6.  
  7. print(unitRealm and unitName.."(*)" or unitName)

What is happening here is that strsplit will pass everything before and after the defined delimiter to as many variables as we allow it to. NAME-REALM keys are always delimited by a "-", and I am almost positive that no REALM keys contain a "-", thus we can safely split the name from the realm in this way. If unitRealm becomes defined, we print unitName with "(*)" concatenated; else we print just the name.

This should be quite adaptable, let me know if you need any further assistance.
Will this just work on Party member names or all name game wide?

Coke
  Reply With Quote