Thread Tools Display Modes
06-03-14, 03:32 PM   #1
rup33rt
A Murloc Raider
Join Date: Jun 2014
Posts: 5
AddOn to change FACTION_STANDING_LABEL

Hey, I'm not sure if this is hard to do or even possible, but I'm looking for an addon that changes the faction standing label for a specific faction based on factionID.

These are the ones I'm talking about:
FACTION_STANDING_LABEL1 = "Hated";
FACTION_STANDING_LABEL1_FEMALE = "Hated";
FACTION_STANDING_LABEL2 = "Hostile";
FACTION_STANDING_LABEL2_FEMALE = "Hostile";
FACTION_STANDING_LABEL3 = "Unfriendly";
FACTION_STANDING_LABEL3_FEMALE = "Unfriendly";
FACTION_STANDING_LABEL4 = "Neutral";
FACTION_STANDING_LABEL4_FEMALE = "Neutral";
FACTION_STANDING_LABEL5 = "Friendly";
FACTION_STANDING_LABEL5_FEMALE = "Friendly";
FACTION_STANDING_LABEL6 = "Honored";
FACTION_STANDING_LABEL6_FEMALE = "Honored";
FACTION_STANDING_LABEL7 = "Revered";
FACTION_STANDING_LABEL7_FEMALE = "Revered";
FACTION_STANDING_LABEL8 = "Exalted";
FACTION_STANDING_LABEL8_FEMALE = "Exalted";
If someone could write it for me or give me some pointers I'd really appreciate it.

Thanks in advance!

// rup33rt
  Reply With Quote
06-04-14, 12:51 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Where are you wanting this changed text to be displayed? Text on the bars in the faction pane? Rep increase messages in the chat frame? Something in a specific addon?
__________________
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
06-04-14, 04:17 AM   #3
rup33rt
A Murloc Raider
Join Date: Jun 2014
Posts: 5
Well, preferably on all the places that it's normally displayed, if that makes any sense.
Text on the bars in the faction pane?
This is the most important one though ^_^
  Reply With Quote
06-04-14, 10:41 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The problem with "change it everywhere" is that changing it for only one faction requires hooking the functions that display the text, to make those functions do something differently depending on which faction they're handling. While this is doable for the default UI, there's just no way to do it for "all addons" -- you'd have to write a separate hook for each specific addon you wanted to support.

Here's an example of how (in theory; I didn't test it in-game) you'd hook the function that updates the text in the default UI's factions panel:

Code:
local CustomLabels = {
	-- Argent Dawn
	[529] = { "Hated", "Hostile", "Unfriendly", "Neutral", "Friendly", "Honored", "Revered", "Exalted" },
	-- Bloodsail Buccaneers
	[87] = { "Hated", "Hostile", "Unfriendly", "Neutral", "Friendly", "Honored", "Revered", "Exalted" },
}

hooksecurefunc("ReputationFrame_Update", function()
	local numFactions = GetNumFactions()
	local offset = FauxScrollFrame_GetOffset(ReputationListScrollFrame)
	for i = 1, NUM_FACTIONS_DISPLAYED do
		local index = offset + i
		if index > numFactions then
			return
		end
		local _, _, standingID, _, _, _, _, _, _, _, _, _, _, factionID = GetFactionInfo(index)
		local labels = CustomLabels[factionID]
		if labels then
			_G["ReputationBar"..i.."ReputationBarFactionStanding"]:SetText(labels[standingID])
		end
	end
end)
You'd add a similar hook for any other functions you wanted to modify. Your hook function should generally be a stripped-down version of the original function -- the original function will still run first, so your function only needs to do the things that need to be done differently. You don't need more copies of the data table at the top; all the functions can refer to the same table.
__________________
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
06-13-14, 12:03 PM   #5
rup33rt
A Murloc Raider
Join Date: Jun 2014
Posts: 5
Can't seem to get it to work with the code you posted no matter how much I try, have you tried it yourself? I'm a rookie at this. :/
  Reply With Quote
06-13-14, 04:43 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by rup33rt View Post
Can't seem to get it to work with the code you posted no matter how much I try, have you tried it yourself? I'm a rookie at this. :/
As stated in my post:
Originally Posted by Phanx View Post
Here's an example of how (in theory; I didn't test it in-game) you'd hook the function that updates the text in the default UI's factions panel:
Did you remember to change the labels to something other than the default values? The code I posted will have no visible effect as-is because the labels are just the default ones. Also, do you have either of the listed factions in your factions list, or did you add at least one faction you actually have listed? If you did both of those things and it's still "not working" please provide more detail, such as the error message as shown by BugSack.
__________________
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
06-13-14, 10:41 PM   #7
rup33rt
A Murloc Raider
Join Date: Jun 2014
Posts: 5
Did you remember to change the labels to something other than the default values? The code I posted will have no visible effect as-is because the labels are just the default ones. Also, do you have either of the listed factions in your factions list, or did you add at least one faction you actually have listed?
Yeah, I tried with several different factions that I have in my list and I obviously changed the labels in the AddOn.

If you did both of those things and it's still "not working" please provide more detail, such as the error message as shown by BugSack.
No error of any kind is showing up in Bugsack. :/
  Reply With Quote
06-13-14, 11:14 PM   #8
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The script works, so you're doing something wrong, maybe you don't have the right faction IDs.

It will have to be modified though because the bars have an OnLeave script that resets the faction label when you mouse on and off of them (it sets it to self.standingText, which is probably _G["ReputationBar"..i] in this context).

Last edited by semlar : 06-13-14 at 11:18 PM.
  Reply With Quote
06-14-14, 12:26 AM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by semlar View Post
TIt will have to be modified though because the bars have an OnLeave script that resets the faction label when you mouse on and off of them (it sets it to self.standingText, which is probably _G["ReputationBar"..i] in this context).
Change the part in green (near the end) to take care of that:

Code:
local CustomLabels = {
	-- Argent Dawn
	[529] = { "Hated", "Hostile", "Unfriendly", "Neutral", "Friendly", "Honored", "Revered", "Exalted" },
	-- Bloodsail Buccaneers
	[87] = { "Hated", "Hostile", "Unfriendly", "Neutral", "Friendly", "Honored", "Revered", "Exalted" },
}

hooksecurefunc("ReputationFrame_Update", function()
	local numFactions = GetNumFactions()
	local offset = FauxScrollFrame_GetOffset(ReputationListScrollFrame)
	for i = 1, NUM_FACTIONS_DISPLAYED do
		local index = offset + i
		if index > numFactions then
			return
		end
		local _, _, standingID, _, _, _, _, _, _, _, _, _, _, factionID = GetFactionInfo(index)
		local labels = CustomLabels[factionID]
		if labels then
			local text = labels[standingID]
			_G["ReputationBar"..i].standingText = text
			_G["ReputationBar"..i.."ReputationBarFactionStanding"]:SetText(text)
		end
	end
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.

Last edited by Phanx : 06-14-14 at 02:42 PM.
  Reply With Quote
06-14-14, 12:33 AM   #10
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
It should be _G["ReputationBar"..i].standingText = text, it's not a key under the label.
  Reply With Quote
06-14-14, 02:43 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Fixed. (10 char min)
__________________
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
06-14-14, 04:14 PM   #12
rup33rt
A Murloc Raider
Join Date: Jun 2014
Posts: 5
Thanks guys, it's working flawlessly now! I'm trying to sort out the FACTION_STANDING_CHANGED strings now, no success though.
  Reply With Quote
06-21-14, 11:59 AM   #13
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Again, not tested, but try adding this to the bottom of the previous code:

Code:
local searchPattern = strsub(FACTION_STANDING_CHANGED, "%%%d?$?s", "(.+)")
local swapResults = strmatch(FACTION_STANDING_CHANGED, "%%2$s.+%%1$s")

ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", function(frame, event, message, ...)
	local faction, standing = strmatch(message, searchPattern)
	if not faction or not standing then return end
	if swapResults then
		faction, standing = standing, faction
	end
	for factionID, labels in pairs(CustomLabels) do
		local name, _, standingID = GetFactionInfoByID(factionID)
		if name == faction then
			message = format(FACTION_STANDING_CHANGED, faction, labels[standingID])
		end
	end
	return false, message, ...
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

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » AddOn to change FACTION_STANDING_LABEL

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