Thursday, April 19, 2012

Reputation text not showing!

Hello again. New problem I would like some help with please!

Sorry about the double posting, wasn't sure where exactly to post this.

I have managed to get the faction name to display but it only shows up after you reload the UI. It is missing when you log in or change characters and if you change your tracked faction, the new name only shows after you reload the UI again. I know something is missing but can't work out what is needed to get it to show and update as necessary.

This is the lua code that I'm using so far.


Code:
---------------------------------------------------------------------------------------
-- Show the Portrait, the Character Name and the current Tracked Faction
---------------------------------------------------------------------------------------
MyReputationFrame_Save = {}
local selfPlayer = nil -- table reference
local selfPlayerName = nil -- string
local selfPlayerRealm = nil -- string
local MYREPUTATION_UIPANELWINDOWS_TABLE = {area = "left", pushable = 11, whileDead = 1} -- UI Panel layout to be used
local MyReputation_UpdateFrame
local factionNameCurrent = GetWatchedFactionInfo()

MyReputationFrame_UpdateFrame = CreateFrame("Frame")

function MyReputationFrame_OnLoad ()
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("UNIT_NAME_UPDATE");
this:RegisterEvent("UNIT_PORTRAIT_UPDATE");
this:RegisterEvent("PLAYER_PVP_RANK_CHANGED");
this:RegisterEvent("FACTION_UPDATE");

getglobal(UNIT_PORTRAITS[unit]):Show();
getglobal(UNIT_NAME[unit]):Show();
MyFactionNameText_factionNameCurrent:Show();
end

function MyReputationFrame_OnEvent (self, event, ...)
if ( not self:IsShown() ) then
return;
end

local arg1 = ...;
if ( event == "UNIT_PORTRAIT_UPDATE" ) then
if ( arg1 == "player" ) then
SetPortraitTexture(MyCharacterFramePortrait, arg1);
end
return;
elseif ( event == "UNIT_NAME_UPDATE" ) then
if ( arg1 == "player" ) then
MyCharacterNameText:SetText(UnitName(arg1));
end
return;
elseif ( event == "FACTION_UPDATE" ) then
if ( arg1 == "name" ) then
MyFactionNameText:SetText(factionNameCurrent(arg1));
end
return;
elseif ( event == "PLAYER_PVP_RANK_CHANGED" ) then
MyCharacterNameText:SetText(UnitPVPName("player"));
end
end

function MyReputationFrame_OnShow (self)
SetPortraitTexture(MyCharacterFramePortrait, "player");
MyCharacterNameText:SetText(UnitPVPName("player"));
MyFactionNameText:SetText(factionNameCurrent, "name");
end

Here's hoping for some help and again thanks in advance.

No comments:

Post a Comment