View Single Post
03-31-14, 11:16 AM   #26
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
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.

Last edited by Clamsoda : 03-31-14 at 11:23 AM.
  Reply With Quote