Thread: Honor Tracking
View Single Post
02-07-17, 03:53 PM   #10
briskman3000
A Flamescale Wyrmkin
 
briskman3000's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 108
Originally Posted by Fizzlemizz View Post
If you move all the fontstring creation/placement up to where you create the frame you should be good.

Something like:
Lua Code:
  1. local Addon, events = CreateFrame("Frame", "LegionHonor", UIParent), {};
  2. Addon:SetWidth(150);
  3. Addon:SetHeight(200);
  4. Addon:SetPoint("CENTER", UIParent, "CENTER");
  5. Addon:SetMovable(true);
  6. Addon:EnableMouse(true);
  7. Addon:RegisterForDrag("LeftButton");
  8. Addon:SetScript("OnDragStart", Addon.StartMoving);
  9. Addon:SetScript("OnDragStop", Addon.StopMovingOrSizing);
  10. Addon:SetClampedToScreen(true);
  11. Addon.Title = Addon:CreateFontString("LegionHonor_Title", "OVERLAY", "GameFontNormal");
  12. Addon.Title:SetPoint("TOP");
  13. Addon.Title:SetText("Legion Honor");
  14. local tex = Addon:CreateTexture(nil, "BACKGROUND")
  15. tex:SetAllPoints()
  16. tex:SetColorTexture(0, 0, 0, 0.5)
  17. Addon.PrestigeLevelText = Addon:CreateFontString("LegionHonor_PrestigeText", "OVERLAY", "GameFontNormal");
  18. Addon.PrestigeLevelText:SetPoint("LEFT", 0, 75);
  19. Addon.PrestigeLevelText:SetText("Prestige Level");
  20. Addon.HonorLevelText = Addon:CreateFontString("LegionHonor_HonorLevelText", "OVERLAY", "GameFontNormal");
  21. Addon.HonorLevelText:SetPoint("LEFT", 0, 25);
  22. Addon.HonorLevelText:SetText("Honor Level");
  23. Addon.HonorAmountText = Addon:CreateFontString("LegionHonor_HonorText", "OVERLAY", "GameFontNormal");
  24. Addon.HonorAmountText:SetPoint("LEFT", 0, -25);
  25. Addon.HonorAmountText:SetText("Current Honor");
  26. Addon.HonorNeededText = Addon:CreateFontString("LegionHonor_HonorNeeded", "OVERLAY", "GameFontNormal");
  27. Addon.HonorNeededText:SetPoint("LEFT", 0, -75);
  28. Addon.HonorNeededText:SetText("Honor to Level");
  29. Addon.PlayerPrestigeLevel = Addon:CreateFontString("LegionHonor_PlayerPrestigeLevel", "OVERLAY", "GameFontNormal");
  30. Addon.PlayerPrestigeLevel:SetPoint("RIGHT", 0, 75);
  31. Addon.PlayerHonorAmount = Addon:CreateFontString("LegionHonor_PlayerHonor", "OVERLAY", "GameFontNormal");
  32. Addon.PlayerHonorAmount:SetPoint("RIGHT", 0, -25);
  33. Addon.PlayerHonorLevel = Addon:CreateFontString("LegionHonor_PlayerHonorLevel", "OVERLAY", "GameFontNormal");
  34. Addon.PlayerHonorLevel:SetPoint("RIGHT", 0, 25);
  35. Addon.PlayerHonorNeeded = Addon:CreateFontString("LegionHonor_PlayerHonorNeeded", "OVERLAY", "GameFontNormal");
  36. Addon.PlayerHonorNeeded:SetPoint("RIGHT", 0, -75);
  37.  
  38.  
  39. local function UpdateHonor(self)
  40.     local lhprestige, lhhonor, lhhonormax, lhhonorlevel, lhhonorneeded;
  41.     lhprestige = UnitPrestige("Player");
  42.     lhhonor = UnitHonor("player");
  43.     lhhonormax = UnitHonorMax("player")
  44.     lhhonorlevel = UnitHonorLevel("player")
  45.     lhhonorneeded = lhhonormax - lhhonor;
  46.     self.PlayerPrestigeLevel:SetText(lhprestige);
  47.     self.PlayerHonorAmount:SetText(lhhonor);
  48.     self.PlayerHonorLevel:SetText(lhhonorlevel);
  49.     self.PlayerHonorNeeded:SetText(lhhonorneeded);
  50. end
  51.  
  52. function events:PLAYER_ENTERING_WORLD(...)
  53.     UpdateHonor(self)
  54. end
  55.  
  56. function events:PLAYER_PVP_KILLS_CHANGED(...)
  57.     UpdateHonor(self)
  58. end
  59.  
  60. Addon:SetScript("OnEvent", function(self, event, ...)
  61.  events[event](self, ...);
  62. end);
  63.  
  64. for k, v in pairs(events) do
  65.  Addon:RegisterEvent(k);
  66. end
Thanks. I'll give that a try when I get home and let you know.
  Reply With Quote