Thread Tools Display Modes
05-21-14, 01:26 PM   #1
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Always include realm name

Just a quick check.. would this ever not work to make sure realm name is always included?

Code:
if not name:match("%-") then
	name = name.."-"..gsub(GetRealmName(), " ", "")
end
Assuming it's either the full realm name or nothing, which will be the case for any CHAT_MSG event, yes? And realm name will always be there for messages from other realms, yes?

Do realm names ever have spaces in them nowadays in API contexts? (except for GetRealmName then)
__________________
Grab your sword and fight the Horde!

Last edited by Lombra : 05-21-14 at 01:29 PM.
  Reply With Quote
05-21-14, 05:24 PM   #2
Shaft840
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jan 2014
Posts: 3
Hey Lombra,

That code should do the trick, or something like

Code:
if not string.find(name, "-") then
	name = name.."-"..string.gsub(GetRealmName(), " ", "")
end
CHAT_MSG_WHISPER
From what I remember, player is usually good with the realm name attached.

CHAT_MSG_WHISPER_INFORM
It depends, If the player does not enter -"realm" after the name then it will not be attached. If they do, it should.

Either way your code to check it is well used.

You are right that 2 word realm names have no spaces unless it is GetRealmName()
  Reply With Quote
05-21-14, 07:32 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Use UnitFullName("player") instead of GetRealmName() -- this way you don't have to strip out spaces, or any other characters Blizz decides to remove in the future, since it's already properly formatted:

Code:
if not string.find(name, "-") then
	local _, realm = UnitFullName("player")
	name = name.."-"..realm
end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
05-22-14, 01:20 AM   #4
Sharparam
A Flamescale Wyrmkin
 
Sharparam's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 102
But what if you don't have a unit handy?
  Reply With Quote
05-22-14, 02:39 AM   #5
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Ah, cool. Didn't know about that.

Originally Posted by Sharparam View Post
But what if you don't have a unit handy?
That's what I thought, too, but the point is to use the return from the player unit for all senders that has no realm name, which should only be ones that are from my realm.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
05-22-14, 03:06 AM   #6
Sharparam
A Flamescale Wyrmkin
 
Sharparam's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 102
At least if Blizzard has finally decided how to handle cross-realm stuff across the board. It seemed to be going back and forth several times over. Removing and adding realm suffixes like crazy...
  Reply With Quote
05-22-14, 06:18 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Sharparam View Post
At least if Blizzard has finally decided how to handle cross-realm stuff across the board. It seemed to be going back and forth several times over. Removing and adding realm suffixes like crazy...
It's still hit-or-miss which API functions will accept a name-realm combo or only a name. Many functions that normally accept a name (for units in your group) currently fail if a realm name is included, eg. CheckInteractDistance or InviteUnit.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Always include realm name


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