Thread Tools Display Modes
09-21-15, 03:16 AM   #1
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Getting rid of realm suffixes

I have been trying to find a solution to something that has been bothering me for a while now. The realm names that you see behind a person's name have been bothering me to no end. i.e. Gryns-Aggrammar. They feel like clutter, and it has been my undying mission to get rid of them everywhere.

With the help of a wide variety of addons and scripts I have removed them from chat, raid frames, and now, thanks to TipTac -tooltips. And even though TipTac removes them from player tooltips, it leaves the realm names in a few other tooltips. Amongst which; in the tooltip for pets and companions (Gryns-Aggramar's Pet/Companion/Minion), and as a loot/dead body tooltip in a party/raid (belongs to Gryns-Aggramar).

Now I've kludged together a solution for the pet/companion tooltips (through hours of experimentation, because I know nothing about LUA code. But I can't find a solution for the loot/dead body tooltip.

Here are the parts of the code that I ruined so it serves my own purpose;

" -- Find NPC Title -- 09.08.22: Should now work with colorblind mode
if (first) and (not u.isPlayer) then
u.title = (isColorBlind and GameTooltipTextLeft3 or GameTooltipTextLeft2):GetText();
if (u.title) and (u.title:find(TT_LevelMatch)) or (u.title:find("-")) then
u.title = nil; "

This is for the pets, it changes the owner line to a class and level line, not ideal, but at least the damn realm name is gone.

" -- BattlePets
elseif (isPetWild or isPetCompanion) then
lineOne[#lineOne + 1] = reaction;
lineOne[#lineOne + 1] = name;
lineInfo[#lineInfo + 1] = " ";
lineInfo[#lineInfo + 1] = cfg.colRace;
local petType = UnitBattlePetType(unit) or 5;
lineInfo[#lineInfo + 1] = name;
if (isPetWild) then
lineInfo[#lineInfo + 1] = " ";
lineInfo[#lineInfo + 1] = UnitCreatureFamily(unit) or UnitCreatureType(unit);
else
if not (petLevelLineIndex) then
for i = 2, gtt:NumLines() do
local gttLineText = _G["GameTooltipTextLeft"..i]:GetText();
if (type(gttLineText) == "string") and (gttLineText:find("-")) then
petLevelLineIndex = i;
break;
end
end
end
lineInfoIndex = petLevelLineIndex or 2;
local expectedLine = 3 + (isColorBlind and 1 or 0);
if (lineInfoIndex > expectedLine) then
GameTooltipTextLeft2:SetFormattedText("%s%s",reaction,u.title);
end
end "

This is for companions and battle pets, again not ideal, because this changes the owner line to the level and name of the pet, and only works if the pet does not have a custom name. But at least the damn realm name is gone.

I was wondering if anyone could help me out with the code, I would like to remove the realm suffix from the pets and companions tooltips and the loot/dead body tooltip.

I don't mind just the player's name, I would just like to get the realm-suffix removed. If that's not possible, then lets remove the whole bloody line.

Thanks in advance,

Gryns.

PS.
There are also a few places where the suffixes still are but if they are possible to remove as well, then by all means, let's get them too. These are the current target floating name, and in chat whispers. These still contain the realm suffixes for some reason.
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-22-15, 02:10 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Possibly slightly overengineered, and not actually tested, but this should take care of pets, corpse loot** and any other unit tooltip line patterns you choose to add:
Code:
local ownerStrings = {
	["(%s)'s Companion"] = "%s's Companion",
	["(%s)'s Guardian"] = "%s's Companion",
	["(%s)'s Minion"] = "%s's Companion",
	["(%s)'s Pet"] = "%s's Companion",
	["(%s)'s Totem"] = "%s's Companion",
	-- ** for corpse loot, add the patterns here; I don't know what it looks like offhand
}

local shortVersions = setmetatable({}, {
	__mode = "kv",
	__index = function(t, k)
		for search, replace in pairs(ownerStrings) do
			local owner = strmatch(text, search)
			if owner then
				local v = format(replace, (gsub(owner, "%-.+", "")))
				t[k] = v
				return v
			end
		end
		t[k] = false
	end
})

GameTooltip:HookScript("OnTooltipSetUnit", function(tooltip)
	local _, unit = tooltip:GetUnit()
	if UnitIsBattlePet(unit)
	or (UnitIsDead(unit) and not UnitPlayerControlled(unit)) then
		for i = 2, tooltip:NumLines() do -- no need to check line 1, it's always the unit's name
			local line = _G["GameTooltipTextLeft"..i]
			local text = shortVersions[line:GetText() or ""]
			if text then
				line:SetText(text)
			end
		end
	end
end)
This (also not tested) will take care of chat whispers (and all other linked player names in chat):
Code:
local orig_AddMessage = {}

local AddMessage = function(frame, message, ...)
	if type(message) == "string" then
		message = gsub("|Hplayer:(.-)|h%[([^%-]+)%-[^|]+([^%]]*)%]|h", "|Hplayer:%1|h[%2%3]|h")
		return orig_AddMessage(frame, message, ...)
	end
end

for i = 1, NUM_CHAT_WINDOWS do
	local f = _G["ChatFrame" .. i])
	orig_AddMessage[f] = f.AddMessage
	f.AddMessage = AddMessage
end

local orig_FCF_OpenTemporaryWindow = FCF_OpenTemporaryWindow
FCF_OpenTemporaryWindow = function(...)
	local f = orig_FCF_OpenTemporaryWindow(...)
	orig_addMessage[f] = f.AddMessage
	f.AddMessage = AddMessage
	return f
end
Depending on what you mean by "current target floating name" that may not be possible. If it's the name that is attached to the actual unit model in the 3D game world, addons can't touch or even see that.
__________________
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
09-22-15, 04:40 AM   #3
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Hey Phanx, thanks for the quick reply.

Tried both your scripts, but both failed to work. I put them both in separate addons, and added the corpse loot pattern to your first script.

Here's what I used for the tooltips.

Code:
 local ownerStrings = {
	["(%s)'s Companion"] = "%s's Companion",
	["(%s)'s Guardian"] = "%s's Guardian",
	["(%s)'s Minion"] = "%s's Minion",
	["(%s)'s Pet"] = "%s's Pet",
	["(%s)'s Totem"] = "%s's Totem",
  	["Loot: (%s)"] = "Loot: %s",
}

local shortVersions = setmetatable({}, {
	__mode = "kv",
	__index = function(t, k)
		for search, replace in pairs(ownerStrings) do
			local owner = strmatch(text, search)
			if owner then
				local v = format(replace, (gsub(owner, "%-.+", "")))
				t[k] = v
				return v
			end
		end
		t[k] = false
	end
})

GameTooltip:HookScript("OnTooltipSetUnit", function(tooltip)
	local _, unit = tooltip:GetUnit()
	if UnitIsBattlePet(unit)
	or (UnitIsDead(unit) and not UnitPlayerControlled(unit)) then
		for i = 2, tooltip:NumLines() do -- no need to check line 1, it's always the unit's name
			local line = _G["GameTooltipTextLeft"..i]
			local text = shortVersions[line:GetText() or ""]
			if text then
				line:SetText(text)
			end
		end
	end
end)
And this is what I used for the chat.

Code:
 local orig_AddMessage = {}

local AddMessage = function(frame, message, ...)
	if type(message) == "string" then
		message = gsub("|Hplayer:(.-)|h%[([^%-]+)%-[^|]+([^%]]*)%]|h", "|Hplayer:%1|h[%2%3]|h")
		return orig_AddMessage(frame, message, ...)
	end
end

for i = 1, NUM_CHAT_WINDOWS do
	local f = _G["ChatFrame" .. i])
	orig_AddMessage[f] = f.AddMessage
	f.AddMessage = AddMessage
end

local orig_FCF_OpenTemporaryWindow = FCF_OpenTemporaryWindow
FCF_OpenTemporaryWindow = function(...)
	local f = orig_FCF_OpenTemporaryWindow(...)
	orig_addMessage[f] = f.AddMessage
	f.AddMessage = AddMessage
	return f
end
I didn't edit this one at all.

This is what I used for chat before, which removed the suffixes from the chat channels, but not from the whispers.

Code:
 local a = getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage
getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage = function(s,t,...)
	return a(s,t:gsub("|Hplayer:(.-)|h%[([^-]+).-%]","|Hplayer:%1|h[%2]"),...)	
end
I used http://addon.bool.no/ to convert both scripts to addons. Is there anything I forgot or did wrong?

Thanks again,

Gryns
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-22-15, 08:06 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
There's probably an error; I didn't test either in-game. Install Bugger and report back with the errors from each.
__________________
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
09-22-15, 10:10 PM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by Gryns View Post
This is what I used for chat before, which removed the suffixes from the chat channels, but not from the whispers.

Code:
local a = getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage
getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage = function(s,t,...)
	return a(s,t:gsub("|Hplayer:(.-)|h%[([^-]+).-%]","|Hplayer:%1|h[%2]"),...)	
end
Since this is from my addon NoRealm, I figured I'd chime in.

Unless you're running an addon that's interfering with it, or you're talking about battle net whispers (which I don't even think can contain a realm?), that should still be removing the realm name from the chat.

I know Prat was causing issues with the original pattern I was using because of all the junk they added to the player link (mostly class coloring), but that was fixed in the more recent version of the addon than what you posted here.
  Reply With Quote
09-23-15, 09:26 AM   #6
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Originally Posted by semlar View Post
Since this is from my addon NoRealm, I figured I'd chime in.

Unless you're running an addon that's interfering with it, or you're talking about battle net whispers (which I don't even think can contain a realm?), that should still be removing the realm name from the chat.

I know Prat was causing issues with the original pattern I was using because of all the junk they added to the player link (mostly class coloring), but that was fixed in the more recent version of the addon than what you posted here.
Hey Semlar, didn't know the script was from your addon, found it in a thread somewhere.

I use BasicChatMods, but even with that disabled it doesn't filter the suffix. Don't get me wrong though, it does remove it from the main chat window, just not when you type. To clarify, when I click on a name in trade chat for instance, it will show "Tell Semlar-Aggramar:" when you are typing in your message, but the conversation itself has the realm suffix removed. I would just like the realm suffix removed in the edit box as well as in the chat window. If that's at all possible, of course.

Originally Posted by Phanx View Post
There's probably an error; I didn't test either in-game. Install Bugger and report back with the errors from each.
I did, and here are the reports.

As for the tooltips. Variations of these showed when mousing over a pet/companion/bodyguard/etc:

Code:
95x TooltipHideRealm\code.lua:17: bad argument #1 to 'strmatch' (string expected, got nil)
[C]:: in function 'strmatch'
TooltipHideRealm\code.lua:17: in function <TooltipHideRealm\code.lua:15>
TooltipHideRealm\code.lua:34: in function <TooltipHideRealm\code.lua:28>
[C]:: ?
[C]:: ?
[C]:: ?

Locals:
t = <table>
k = "Minalla-Silvermoon's Companion"
(for generator) = <function> defined =[C]:-1
(for state) = <table> {
 (%s)'s Minion = "%s's Minion"
 (%s)'s Totem = "%s's Totem"
 (%s)'s Companion = "%s's Companion"
 Loot: (%s) = "Loot : %s"
 (%s)'s Pet = "%s's Pet"
 (%s)'s Guardian = "%s's Guardian"
}
(for control) = "(%s)'s Minion"
search = "(%s)'s Minion"
replace = "%s's Minion"
ownerStrings = <table> {
 (%s)'s Minion = "%s's Minion"
 (%s)'s Totem = "%s's Totem"
 (%s)'s Companion = "%s's Companion"
 Loot: (%s) = "Loot : %s"
 (%s)'s Pet = "%s's Pet"
 (%s)'s Guardian = "%s's Guardian"
}

And variations of these when you moused over a corpse that had loot assigned to a party/raid member:

Code:
82x TooltipHideRealm\code.lua:17: bad argument #1 to 'strmatch' (string expected, got table)
[C]:: in function 'strmatch'
TooltipHideRealm\code.lua:17: in function <TooltipHideRealm\code.lua:15>
TooltipHideRealm\code.lua:34: in function <TooltipHideRealm\code.lua:28>
[C]:: ?
[C]:: ?
[C]:: ?

Locals:
t = <table>
k = "Shadow Council"
(for generator) = <function> defined =[C]:-1
(for state) = <table> {
 (%s)'s Minion = "%s's Minion"
 (%s)'s Totem = "%s's Totem"
 (%s)'s Companion = "%s's Companion"
 Loot: (%s) = "Loot : %s"
 (%s)'s Pet = "%s's Pet"
 (%s)'s Guardian = "%s's Guardian"
}
(for control) = "(%s)'s Minion"
search = "(%s)'s Minion"
replace = "%s's Minion"
ownerStrings = <table> {
 (%s)'s Minion = "%s's Minion"
 (%s)'s Totem = "%s's Totem"
 (%s)'s Companion = "%s's Companion"
 Loot: (%s) = "Loot : %s"
 (%s)'s Pet = "%s's Pet"
 (%s)'s Guardian = "%s's Guardian"
}

And for chat:

Code:
1x ChatHideRealm\code.lua:14: unexpected symbol near ')'

Which if I had to guess, is this part of the script:

Code:
for i = 1, NUM_CHAT_WINDOWS do
	local f = _G["ChatFrame" .. i])
	orig_AddMessage[f] = f.AddMessage
	f.AddMessage = AddMessage
end
Thanks for the help, both of you.

Gryns
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-23-15, 01:56 PM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by Gryns View Post
And for chat:

Code:
1x ChatHideRealm\code.lua:14: unexpected symbol near ')'

Which if I had to guess, is this part of the script:

Code:
for i = 1, NUM_CHAT_WINDOWS do
	local f = _G["ChatFrame" .. i])
	orig_AddMessage[f] = f.AddMessage
	f.AddMessage = AddMessage
end
The error is from 'local f = _G["ChatFrame" .. i])' having an extraneous parentheses at the end, but I don't think phanx's script is going to do anything mine didn't do for you, it's just a different way of doing more or less the same thing.

Originally Posted by Gryns View Post
I use BasicChatMods, but even with that disabled it doesn't filter the suffix. Don't get me wrong though, it does remove it from the main chat window, just not when you type. To clarify, when I click on a name in trade chat for instance, it will show "Tell Semlar-Aggramar:" when you are typing in your message, but the conversation itself has the realm suffix removed. I would just like the realm suffix removed in the edit box as well as in the chat window. If that's at all possible, of course.
If I'm understanding you correctly it's removing the realm from their name in the chat window when they send you a whisper, but you want it to also remove it from the left side of the chat box when you're sending a tell to someone.

Alright, I threw something together that I think should do what you're after.
Lua Code:
  1. hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
  2.     local header = _G[editBox:GetName() .. 'Header']
  3.     if editBox:GetAttribute('chatType') == 'WHISPER' and header then
  4.         _G[editBox:GetName() .. 'HeaderSuffix']:Hide()
  5.         header:SetWidth(0)
  6.         header:SetFormattedText(CHAT_WHISPER_SEND, (strsplit('-', editBox:GetAttribute('tellTarget'))))
  7.         editBox:SetTextInsets(15 + (header:GetRight() or 0) - (header:GetLeft() or 0), 13, 0, 0)
  8.     end
  9. end)

Last edited by semlar : 09-23-15 at 03:01 PM.
  Reply With Quote
09-24-15, 02:26 PM   #8
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Originally Posted by semlar View Post
The error is from 'local f = _G["ChatFrame" .. i])' having an extraneous parentheses at the end, but I don't think phanx's script is going to do anything mine didn't do for you, it's just a different way of doing more or less the same thing.


If I'm understanding you correctly it's removing the realm from their name in the chat window when they send you a whisper, but you want it to also remove it from the left side of the chat box when you're sending a tell to someone.

Alright, I threw something together that I think should do what you're after.
Lua Code:
  1. hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
  2.     local header = _G[editBox:GetName() .. 'Header']
  3.     if editBox:GetAttribute('chatType') == 'WHISPER' and header then
  4.         _G[editBox:GetName() .. 'HeaderSuffix']:Hide()
  5.         header:SetWidth(0)
  6.         header:SetFormattedText(CHAT_WHISPER_SEND, (strsplit('-', editBox:GetAttribute('tellTarget'))))
  7.         editBox:SetTextInsets(15 + (header:GetRight() or 0) - (header:GetLeft() or 0), 13, 0, 0)
  8.     end
  9. end)
Brilliant! This is exactly what I wanted, seems to filter everything now, except the realm names in system messages. i.e. "Gryns-Aggramar has entered the raid" I know I'm nitpicking, but is that possible as well?

Also, I added this to the code of your other addon, NoRealm, but that didn't seem to work. It only seemed to work when I enabled it as a separate addon, how can I merge the two?

Thanks again, really.

Joey
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-24-15, 03:20 PM   #9
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by Gryns View Post
seems to filter everything now, except the realm names in system messages. i.e. "Gryns-Aggramar has entered the raid" I know I'm nitpicking, but is that possible as well?
It's not filtering them because they aren't actual player links, which is what the script is looking for.

The problem with the system messages is that you'll either need to use a pattern verbose enough to match almost ANYTHING with a hyphen in it (which I'm not sure is really an issue) or make a list of all of the global strings that might contain a player name (which would be a nightmare to compile).

The fact that players can use unicode characters in their names complicates things (not to mention other languages).

I'm not sure whether it will actually work, but you can try something like this..
Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_SYSTEM', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^\0%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[\0%s]', '%1')), ...
  3. end)

Originally Posted by Gryns View Post
I added this to the code of your other addon, NoRealm, but that didn't seem to work. It only seemed to work when I enabled it as a separate addon, how can I merge the two?
You can just paste it into the end of the file, just make sure you don't remove anything when you do it.
Lua Code:
  1. local a,g = getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage,gsub
  2. getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage = function(s,t,...)
  3.     if s == ChatFrame2 then return a(s,t,...) end -- combat log
  4.     return a(s,g(t,"|Hplayer:(.-)|h(.-)|h",function(a,b)
  5.         return "|Hplayer:"..a.."|h"..g(b,"-([^%]:]+)(.*)","%2|r").."|h"
  6.     end),...)
  7. end
  8.  
  9. hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
  10.     local header = _G[editBox:GetName() .. 'Header']
  11.     if editBox:GetAttribute('chatType') == 'WHISPER' and header then
  12.         _G[editBox:GetName() .. 'HeaderSuffix']:Hide()
  13.         header:SetWidth(0)
  14.         header:SetFormattedText(CHAT_WHISPER_SEND, (strsplit('-', editBox:GetAttribute('tellTarget'))))
  15.         editBox:SetTextInsets(15 + (header:GetRight() or 0) - (header:GetLeft() or 0), 13, 0, 0)
  16.     end
  17. end)
The addon's from 2012 so if you don't want it marked as "out of date" you'll need to bump the version in the toc file to 60200.

Last edited by semlar : 09-24-15 at 03:29 PM.
  Reply With Quote
09-24-15, 11:02 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Gryns View Post
As for the tooltips. Variations of these showed when mousing over a pet/companion/bodyguard/etc:
Change this line:
Code:
local owner = strmatch(text, search)
to this:
Code:
local owner = strmatch(k, search)
__________________
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
09-25-15, 07:18 AM   #11
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Originally Posted by semlar View Post
You can just paste it into the end of the file, just make sure you don't remove anything when you do it.
Lua Code:
  1. local a,g = getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage,gsub
  2. getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage = function(s,t,...)
  3.     if s == ChatFrame2 then return a(s,t,...) end -- combat log
  4.     return a(s,g(t,"|Hplayer:(.-)|h(.-)|h",function(a,b)
  5.         return "|Hplayer:"..a.."|h"..g(b,"-([^%]:]+)(.*)","%2|r").."|h"
  6.     end),...)
  7. end
  8.  
  9. hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
  10.     local header = _G[editBox:GetName() .. 'Header']
  11.     if editBox:GetAttribute('chatType') == 'WHISPER' and header then
  12.         _G[editBox:GetName() .. 'HeaderSuffix']:Hide()
  13.         header:SetWidth(0)
  14.         header:SetFormattedText(CHAT_WHISPER_SEND, (strsplit('-', editBox:GetAttribute('tellTarget'))))
  15.         editBox:SetTextInsets(15 + (header:GetRight() or 0) - (header:GetLeft() or 0), 13, 0, 0)
  16.     end
  17. end)
The addon's from 2012 so if you don't want it marked as "out of date" you'll need to bump the version in the toc file to 60200.
Alright, merged the two scripts without issue, thanks.

Originally Posted by semlar View Post
It's not filtering them because they aren't actual player links, which is what the script is looking for.

The problem with the system messages is that you'll either need to use a pattern verbose enough to match almost ANYTHING with a hyphen in it (which I'm not sure is really an issue) or make a list of all of the global strings that might contain a player name (which would be a nightmare to compile).

The fact that players can use unicode characters in their names complicates things (not to mention other languages).

I'm not sure whether it will actually work, but you can try something like this..
Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_SYSTEM', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^\0%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[\0%s]', '%1')), ...
  3. end)
I also added the script to try and filter the system messages, but I'm getting this back whenever a system message is put through:

Code:
4x ChatHideRealm\code.lua:13: malformed pattern (missing ']')
[C]:: in function 'gsub'
ChatHideRealm\code.lua:13: in function 'filterFunc'
FrameXML\ChatFrame.lua:2946: in function 'ChatFrame_MessageEventHandler'
FrameXML\ChatFrame.lua:2721: in function 'ChatFrame_OnEvent'
[string "*:OnEvent"]:1: in function <[string "*:OnEvent"]:1>

Locals:
self = ChatFrame1 {
 0 = <userdata>
 isUninteractable = false
 flashTimer = 0
 isInitialized = 1
 mouseOutTime = 0.032999999821186
 tellTimer = 47089.682
 resizeButton = ChatFrame1ResizeButton {
 }
 buttonFrame = ChatFrame1ButtonFrame {
 }
 defaultLanguage = "Common"
 oldAlpha = 0
 channelList = <table> {
 }
 alternativeDefaultLanguage = "Common"
 clickAnywhereButton = ChatFrame1ClickAnywhereButton {
 }
 isStaticDocked = true
 mouseInTime = 0
 editBox = ChatFrame1EditBox {
 }
 checkedGMOTD = true
 isLocked = true
 name = "General"
 buttonSide = "left"
 isDocked = 1
 zoneChannelList = <table> {
 }
 AddMessage = <function> defined @BasicChatMods\BasicCore.lua:70
 messageTypeList = <table> {
 }
}
event = "CHAT_MSG_SYSTEM"
msg = "You have unlearned [Glyph of Contemplation]."
(*temporary) = false
Any idea what that might be?

Originally Posted by Phanx View Post
Change this line:
Code:
local owner = strmatch(text, search)
to this:
Code:
local owner = strmatch(k, search)
Thanks for the response Phanx. I changed the line, and it removed the errors completely. It did not remove the realm suffix from the tooltips however.
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-25-15, 08:24 AM   #12
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Please post exactly what you have in the file.
  Reply With Quote
09-25-15, 08:44 AM   #13
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Originally Posted by semlar View Post
Please post exactly what you have in the file.
Of course, I merged all the scripts that you gave me so far. This is what I have:


Code:
-- This file is loaded from "ChatHideRealm.toc"

-- ChatHideRealm
local a,g = getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage,gsub
getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage = function(s,t,...)
    if s == ChatFrame2 then return a(s,t,...) end -- combat log
    return a(s,g(t,"|Hplayer:(.-)|h(.-)|h",function(a,b)
        return "|Hplayer:"..a.."|h"..g(b,"-([^%]:]+)(.*)","%2|r").."|h"
    end),...)
end

ChatFrame_AddMessageEventFilter('CHAT_MSG_SYSTEM', function(self, event, msg, ...)
    return false, (msg:gsub('%f[^\0%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[\0%s]', '%1')), ...
end)
    
hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
    local header = _G[editBox:GetName() .. 'Header']
    if editBox:GetAttribute('chatType') == 'WHISPER' and header then
        _G[editBox:GetName() .. 'HeaderSuffix']:Hide()
        header:SetWidth(0)
        header:SetFormattedText(CHAT_WHISPER_SEND, (strsplit('-', editBox:GetAttribute('tellTarget'))))
        editBox:SetTextInsets(15 + (header:GetRight() or 0) - (header:GetLeft() or 0), 13, 0, 0)
    end
end)
The error is shown in line 13;
return false, (msg:gsub('%f[^\0%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[\0%s]', '%1')), ...
Which as far as I can tell has all the opening and closing brackets.

I tried using the code as a seperate addon, and Bugger encounters the same error with that same line.
__________________
-- Live like a King, laugh like his Jester. --

Last edited by Gryns : 09-25-15 at 09:22 AM.
  Reply With Quote
09-25-15, 02:24 PM   #14
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Alright, the game is cutting off the string after "\0", which in retrospect I probably should have seen coming since it represents the end of a string.

Try this instead..
Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_SYSTEM', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^%z%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s]', '%1')), ...
  3. end)
  Reply With Quote
09-26-15, 04:02 AM   #15
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Originally Posted by semlar View Post
Alright, the game is cutting off the string after "\0", which in retrospect I probably should have seen coming since it represents the end of a string.

Try this instead..
Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_SYSTEM', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^%z%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s]', '%1')), ...
  3. end)
Brilliant! It worked! I also modified your script to get rid of other messages that still had the realm suffixes in them; emotes, loot messages, tradeskill messages, etc.

Code:
    ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTES', function(self, event, msg, ...)
        return false, (msg:gsub('%f[^%z%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s]', '%1')), ...
    end)
It works for some, but not for other. For instance, it filters the realm suffix from the /hi emote but it doesn't grab the /wave emote for instance. i.e "Semlar greets Gryns with a hearty hello" but, "Semlar waves at "Gryns-Aggramar" Any idea why that is?
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-26-15, 12:26 PM   #16
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by Gryns View Post
It works for some, but not for other. For instance, it filters the realm suffix from the /hi emote but it doesn't grab the /wave emote for instance. i.e "Semlar greets Gryns with a hearty hello" but, "Semlar waves at "Gryns-Aggramar" Any idea why that is?
It's not looking for names with quotes around them, the %f[] at the start and end of the pattern contains a character class representing a transition from any of the characters inside of the brackets to the characters in the name itself.

%s matches any whitespace and %z essentially matches "nothing", which allows it to match the name if it's at the start or end of the message.

So, since "Gryns-Aggramar" is surrounded by quotes and not spaces, the pattern fails.

Add double-quotes to the frontier pattern to allow them to match.
Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTES', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^%z%s"]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s"]', '%1')), ...
  3. end)
  Reply With Quote
09-27-15, 02:31 AM   #17
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Originally Posted by semlar View Post
It's not looking for names with quotes around them, the %f[] at the start and end of the pattern contains a character class representing a transition from any of the characters inside of the brackets to the characters in the name itself.

%s matches any whitespace and %z essentially matches "nothing", which allows it to match the name if it's at the start or end of the message.

So, since "Gryns-Aggramar" is surrounded by quotes and not spaces, the pattern fails.

Add double-quotes to the frontier pattern to allow them to match.
Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTES', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^%z%s"]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s"]', '%1')), ...
  3. end)
Thanks for the explanation. The thing is, I just added the quotes there to underline how the character name is displayed. The quotes are not there in-game. It just uses the name with the realm suffix. Perhaps the reason that this particular piece of code only grabs certain emotes is because it is looking for the name at the start or ending of the sentence?

But I looked up other character classes and tried some other combinations. But none of them seem to work. I'm trying to get the code to look for anything with a hyphen, and then remove the realm suffix.

This is how I tried editing your code:

Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTES', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[-]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s"]', '%1')), ...
  3. end)

This apparently isn't working, and neither are the combinations %f[^-], %f[^%z-], %f[%z%s-]. Any idea how I should try to do it?

Thanks again.
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-27-15, 06:55 AM   #18
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Without seeing exactly what it isn't working with I'm just taking a stab in the dark.

My best guess is it's putting some form of punctuation after the person's name.

If you aren't concerned about it potentially matching something that isn't a name, you can just remove both %f[] patterns from the string and it would match anything that looks like "Name-Realm", regardless of what's around it, otherwise you can try this, which should cover any punctuation.

Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTES', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^%z%s"]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s".,!?\']', '%1')), ...
  3. end)
  Reply With Quote
09-30-15, 09:43 AM   #19
Gryns
A Deviate Faerie Dragon
 
Gryns's Avatar
Join Date: Sep 2015
Posts: 11
Originally Posted by semlar View Post
Without seeing exactly what it isn't working with I'm just taking a stab in the dark.

My best guess is it's putting some form of punctuation after the person's name.

If you aren't concerned about it potentially matching something that isn't a name, you can just remove both %f[] patterns from the string and it would match anything that looks like "Name-Realm", regardless of what's around it, otherwise you can try this, which should cover any punctuation.

Lua Code:
  1. ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTES', function(self, event, msg, ...)
  2.     return false, (msg:gsub('%f[^%z%s"]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s".,!?\']', '%1')), ...
  3. end)
Sorry for the late reply, my CPU died last week, so I decided to upgrade my PC altogether. Tested everything with the scripts you gave me, and so far everything worked like a charm, I manage to remove all realm suffixes from every single message.
I also found a new tooltip addon that removes the suffixes from all existing tooltips, including pet and loot tooltips. Something I've been struggling with. It's called Cloudy Tooltip Mod.

So my mission is nearing completion! The only thing that remains is to remove the floating name that appears when targeting a unit. This target name appears even if names are turned off completely.
So far the only way I've been able to remove these, is by installing a nameplate addon like Tidy Plates, and turning the opacity of all nameplates to 0%. But that just feels like trying to kill a fly with a tank. In order for that to work I need to turn on all the unit nameplates, and then make them all see-through. And even then, when a unit is dead, it still shows the original floating name.

Is there any subtle trick to hiding these names?

Thanks again,

Gryns
__________________
-- Live like a King, laugh like his Jester. --
  Reply With Quote
09-30-15, 12:34 PM   #20
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
As far as I can tell there is no CVar for disabling your target's name.

Turning nameplates on is the only thing that hides it, and since nameplates aren't always visible (such as when it's dead or out of range) and the only other solution I can think of is removing the font entirely (which is used in other areas of the interface), I don't think this can reasonably be done.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Getting rid of realm suffixes


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