Thread Tools Display Modes
11-21-14, 12:34 PM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Reputation Bar Issue

Hi everyone!

I have some issues with FACTION_BAR_COLORS.

Why i dont know

Lua Code:
  1. Message: ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:60: attempt to index field '?' (a nil value)
  2. Time: 11/21/14 19:31:37
  3. Count: 2
  4. Stack: ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:60: in function <...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:55>
  5.  
  6. Locals: FactionColors = <table> {
  7.  6 = <table> {
  8.  }
  9.  2 = <table> {
  10.  }
  11.  8 = <table> {
  12.  }
  13.  3 = <table> {
  14.  }
  15.  1 = <table> {
  16.  }
  17.  4 = <table> {
  18.  }
  19.  5 = <table> {
  20.  }
  21.  7 = <table> {
  22.  }
  23. }
  24. Name = nil
  25. ID = 0
  26. Min = 0
  27. Max = 0
  28. Value = 0
  29. (*temporary) = <function> defined =[C]:-1
  30. (*temporary) = <unnamed> {
  31.  0 = <userdata>
  32.  Shadow = <table> {
  33.  }
  34.  fadeInfo = <table> {
  35.  }
  36.  HasBorder = true
  37.  Border = <table> {
  38.  }
  39. }
  40. (*temporary) = nil
  41. (*temporary) = <userdata>
  42. (*temporary) = <userdata>
  43. (*temporary) = nil
  44. (*temporary) = nil
  45. (*temporary) = nil
  46. (*temporary) = nil
  47. (*temporary) = "attempt to index field '?' (a nil value)"
  48. ReputationBar = <unnamed> {
  49.  0 = <userdata>
  50.  Shadow = <table> {
  51.  }
  52.  fadeInfo = <table> {
  53.  }
  54.  HasBorder = true
  55.  Border = <table> {
  56.  }
  57. }
  58. ReputationBarFont = <unnamed> {
  59.  0 = <userdata>
  60. }


Lua Code:
  1. if AftermathhUI.plugins.repbar == false then return end
  2.  
  3. local Reputation = CreateFrame("Frame", nil, UIParent)
  4.  
  5. local ReputationBar = CreateFrame('StatusBar', nil, UIParent)
  6.  
  7. local InvisFrame = CreateFrame("Frame", nil, ReputationBar)
  8. InvisFrame:SetFrameStrata("HIGH")
  9. InvisFrame:SetFrameLevel(5)
  10. InvisFrame:SetAllPoints()
  11.  
  12. local ReputationBarFont = InvisFrame:CreateFontString(nil, 'OVERLAY')  
  13.  
  14. ReputationBar:SetPoint('LEFT', oUF_AftermathhPlayer, 223, -178)
  15. ReputationBar:SetStatusBarTexture(AftermathhUI.media.texture)
  16. ReputationBar:SetSize(235, 20)
  17. ReputationBar:SetBackdrop({
  18.     bgFile = AftermathhUI.media.blank,
  19.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  20.     })
  21. ReputationBar:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  22.  
  23. CreateBorderLight(ReputationBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 3)
  24.    
  25. ReputationBar:SetScript("OnEnter", function(self)
  26.     if (not GetWatchedFactionInfo()) then
  27.         return
  28.     end
  29.  
  30.     local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  31.     GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  32.     GameTooltip:AddLine(string.format("%s (%s)", Name, _G["FACTION_STANDING_LABEL" .. ID]))
  33.     GameTooltip:AddLine(string.format("%d / %d (%d%%)", Value - Min, Max - Min, (Value - Min) / (Max - Min) * 100), 1, 1, 1, 1, 1, 1)
  34.     GameTooltip:Show()
  35.     GameTooltip:Show()
  36. end)
  37.    
  38. ReputationBar:SetScript("OnLeave", function()
  39.     if GameTooltip:IsShown() then
  40.     GameTooltip:Hide()
  41.     end
  42. end)
  43.  
  44. ReputationBar:SetAlpha(0)
  45. ReputationBar:HookScript("OnEnter", function(self) UIFrameFadeIn(self, 1.2, self:GetAlpha(), 1) end)
  46. ReputationBar:HookScript("OnLeave", function(self) UIFrameFadeIn(self, 0.8, self:GetAlpha(), 0) end)
  47.  
  48. ReputationBarFont:SetPoint('CENTER', ReputationBar)
  49. ReputationBarFont:SetFont(AftermathhUI.media.font, 12, AftermathhUI.media.fontflag)
  50. if AftermathhUI.media.shadowoffset == true then
  51.     ReputationBarFont:SetShadowOffset(1, -1)
  52.     ReputationBarFont:SetShadowColor(0,0,0)
  53. end
  54.  
  55. local function UpdateRep()
  56.     local FactionColors = FACTION_BAR_COLORS
  57.     local Name, ID, Min, Max, Value = GetWatchedFactionInfo()  
  58.     ReputationBar:SetMinMaxValues(Min, Max)
  59.     ReputationBar:SetValue(Value)
  60.     ReputationBar:SetStatusBarColor(FactionColors[ID].r, FactionColors[ID].g, FactionColors[ID].b)
  61.     ReputationBarFont:SetText(""..Min.." / "..Max.." - "..Name.."")
  62. end
  63.  
  64. Reputation:RegisterEvent("UPDATE_FACTION")
  65. Reputation:RegisterEvent("PLAYER_ENTERING_WORLD")
  66.  
  67. Reputation:SetScript("OnEvent", UpdateRep)

Last edited by Aftermathhqt : 11-21-14 at 12:37 PM.
  Reply With Quote
11-21-14, 01:01 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Try this:
Code:
-- comment out or remove line 56
ReputationBar:SetValue(Value)
local c = FACTION_BAR_COLORS[ID]
ReputationBar:SetStatusBarColor(c.r * 255, c.g * 255, c.b * 255)
ReputationBarFont:SetText(""..Min.." / "..Max.." - "..Name.."")
  Reply With Quote
11-21-14, 01:18 PM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by myrroddin View Post
Try this:
Code:
-- comment out or remove line 56
ReputationBar:SetValue(Value)
local c = FACTION_BAR_COLORS[ID]
ReputationBar:SetStatusBarColor(c.r * 255, c.g * 255, c.b * 255)
ReputationBarFont:SetText(""..Min.." / "..Max.." - "..Name.."")
Seems to work, but now this happen

Lua Code:
  1. Message: ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:59: attempt to concatenate local 'Name' (a nil value)
  2. Time: 11/21/14 20:18:28
  3. Count: 8
  4. Stack: ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:59: in function <...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:55>
  5.  
  6. Locals: Name = nil
  7. ID = 0
  8. Min = 0
  9. Max = 0
  10. Value = 0
  11. (*temporary) = <function> defined =[C]:-1
  12. (*temporary) = <unnamed> {
  13.  0 = <userdata>
  14. }
  15. (*temporary) = ""
  16. (*temporary) = 0
  17. (*temporary) = " / "
  18. (*temporary) = 0
  19. (*temporary) = " - "
  20. (*temporary) = nil
  21. (*temporary) = ""
  22. (*temporary) = "attempt to concatenate local 'Name' (a nil value)"
  23. ReputationBar = <unnamed> {
  24.  0 = <userdata>
  25.  Shadow = <table> {
  26.  }
  27.  Border = <table> {
  28.  }
  29.  HasBorder = true
  30. }
  31. ReputationBarFont = <unnamed> {
  32.  0 = <userdata>
  33. }

Lua Code:
  1. if AftermathhUI.plugins.repbar == false then return end
  2.  
  3. local Reputation = CreateFrame("Frame", nil, UIParent)
  4.  
  5. local ReputationBar = CreateFrame('StatusBar', nil, UIParent)
  6.  
  7. local InvisFrame = CreateFrame("Frame", nil, ReputationBar)
  8. InvisFrame:SetFrameStrata("HIGH")
  9. InvisFrame:SetFrameLevel(5)
  10. InvisFrame:SetAllPoints()
  11.  
  12. local ReputationBarFont = InvisFrame:CreateFontString(nil, 'OVERLAY')  
  13.  
  14. ReputationBar:SetPoint('LEFT', oUF_AftermathhPlayer, 223, -178)
  15. ReputationBar:SetStatusBarTexture(AftermathhUI.media.texture)
  16. ReputationBar:SetSize(235, 20)
  17. ReputationBar:SetBackdrop({
  18.     bgFile = AftermathhUI.media.blank,
  19.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  20.     })
  21. ReputationBar:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  22.  
  23. CreateBorderLight(ReputationBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 3)
  24.    
  25. ReputationBar:SetScript("OnEnter", function(self)
  26.     if (not GetWatchedFactionInfo()) then
  27.         return
  28.     end
  29.  
  30.     local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  31.    
  32.     GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  33.     GameTooltip:AddLine(string.format("%s (%s)", Name, _G["FACTION_STANDING_LABEL" .. ID]))
  34.     GameTooltip:AddLine(string.format("%d / %d (%d%%)", Value - Min, Max - Min, (Value - Min) / (Max - Min) * 100), 1, 1, 1, 1, 1, 1)
  35.     GameTooltip:Show()
  36.     GameTooltip:Show()
  37. end)
  38.    
  39. ReputationBar:SetScript("OnLeave", function()
  40.     if GameTooltip:IsShown() then
  41.     GameTooltip:Hide()
  42.     end
  43. end)
  44.  
  45. ReputationBar:SetAlpha(0)
  46. ReputationBar:HookScript("OnEnter", function(self) UIFrameFadeIn(self, 1.2, self:GetAlpha(), 1) end)
  47. ReputationBar:HookScript("OnLeave", function(self) UIFrameFadeIn(self, 0.8, self:GetAlpha(), 0) end)
  48.  
  49. ReputationBarFont:SetPoint('CENTER', ReputationBar)
  50. ReputationBarFont:SetFont(AftermathhUI.media.font, 12, AftermathhUI.media.fontflag)
  51. if AftermathhUI.media.shadowoffset == true then
  52.     ReputationBarFont:SetShadowOffset(1, -1)
  53.     ReputationBarFont:SetShadowColor(0,0,0)
  54. end
  55.  
  56. local function UpdateRep()
  57.     local Name, ID, Min, Max, Value = GetWatchedFactionInfo()  
  58.    
  59.     ReputationBar:SetMinMaxValues(Min, Max)
  60.     ReputationBar:SetValue(Value)
  61.     ReputationBarFont:SetText(""..Min.." / "..Max.." - "..Name.."")
  62.  
  63.     local FactionColors = FACTION_BAR_COLORS[ID]
  64.     ReputationBar:SetStatusBarColor(FactionColors.r, FactionColors.g, FactionColors.b)
  65. end
  66.  
  67. Reputation:RegisterEvent("UPDATE_FACTION")
  68. Reputation:RegisterEvent("PLAYER_ENTERING_WORLD")
  69.  
  70. Reputation:SetScript("OnEvent", UpdateRep)

Last edited by Aftermathhqt : 11-21-14 at 01:31 PM.
  Reply With Quote
11-21-14, 02:22 PM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
line 61 won't work because you are trying to concat strings and numbers incorrectly. You have too many quotes, and also putting both Min and Max in quotes will literally print the words Min and Max, not their values.
Code:
ReputationBarFont:SetText(Min .." / " ..Max .." - " ..Name)
But you are better using
Code:
ReputationBarFont:SetFormattedText("%d / %d - %s", Min, Max, Name)

Last edited by myrroddin : 11-21-14 at 02:25 PM. Reason: switch to SetFormattedText instead
  Reply With Quote
11-21-14, 02:34 PM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by myrroddin View Post
line 61 won't work because you are trying to concat strings and numbers incorrectly. You have too many quotes, and also putting both Min and Max in quotes will literally print the words Min and Max, not their values.
Code:
ReputationBarFont:SetText(Min .." / " ..Max .." - " ..Name)
But you are better using
Code:
ReputationBarFont:SetFormattedText("%d / %d - %s", Min, Max, Name)
Oh, i see

This happend :S

Lua Code:
  1. Message: ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:61: bad argument #4 to 'SetFormattedText' (string expected, got nil)
  2. Time: 11/21/14 21:41:35
  3. Count: 1
  4. Stack: [C]: in function `SetFormattedText'
  5. ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:61: in function <...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:56>
  6.  
  7. Locals: (*temporary) = <unnamed> {
  8. 0 = <userdata>
  9. }
  10. (*temporary) = "%d / %d - %s"
  11. (*temporary) = 0
  12. (*temporary) = 0
  13. (*temporary) = nil
  14. (*temporary) = "string expected, got nil"

Last edited by Aftermathhqt : 11-21-14 at 02:41 PM.
  Reply With Quote
11-21-14, 02:47 PM   #6
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Originally Posted by Game92 View Post
Oh, i see

This happend :S

Lua Code:
  1. Message: ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:61: bad argument #4 to 'SetFormattedText' (string expected, got nil)
  2. Time: 11/21/14 21:41:35
  3. Count: 1
  4. Stack: [C]: in function `SetFormattedText'
  5. ...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:61: in function <...ce\AddOns\AftermathhUI\Modules\Blizzard\AfterRep.lua:56>
  6.  
  7. Locals: (*temporary) = <unnamed> {
  8. 0 = <userdata>
  9. }
  10. (*temporary) = "%d / %d - %s"
  11. (*temporary) = 0
  12. (*temporary) = 0
  13. (*temporary) = nil
  14. (*temporary) = "string expected, got nil"
You're passing a nil value as the fourth argument to SetFormattedText, probably because GetWatchedFactionInfo() returns nil when there's no faction being watched.

You'll need to check that the player is actually watching a faction (i.e. GetWatchedFactionInfo() returns something other than nil) before you try to update the reputation bar. In fact you probably want to hide or disable the bar in some way if no faction is being watched.
  Reply With Quote
11-21-14, 02:47 PM   #7
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Post your full Lua file, please, including any changes. Need to review what it looks like currently.
  Reply With Quote
11-21-14, 02:59 PM   #8
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Guess it should be something like this then?

Lua Code:
  1. if AftermathhUI.plugins.repbar == false then return end
  2.  
  3. local Reputation = CreateFrame("Frame", nil, UIParent)
  4.  
  5. local ReputationBar = CreateFrame('StatusBar', nil, UIParent)
  6.  
  7. local InvisFrame = CreateFrame("Frame", nil, ReputationBar)
  8. InvisFrame:SetFrameStrata("HIGH")
  9. InvisFrame:SetFrameLevel(5)
  10. InvisFrame:SetAllPoints()
  11.  
  12. local ReputationBarFont = InvisFrame:CreateFontString(nil, 'OVERLAY')  
  13.  
  14. ReputationBar:SetPoint('LEFT', oUF_AftermathhPlayer, 223, -178)
  15. ReputationBar:SetStatusBarTexture(AftermathhUI.media.texture)
  16. ReputationBar:SetSize(235, 20)
  17. ReputationBar:SetBackdrop({
  18.     bgFile = AftermathhUI.media.blank,
  19.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  20.     })
  21. ReputationBar:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  22.  
  23. CreateBorderLight(ReputationBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 3)
  24.    
  25. ReputationBar:SetScript("OnEnter", function(self)
  26.     if (not GetWatchedFactionInfo()) then
  27.         return
  28.     end
  29.  
  30.     local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  31.    
  32.     GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  33.     GameTooltip:AddLine(string.format("%s (%s)", Name, _G["FACTION_STANDING_LABEL" .. ID]))
  34.     GameTooltip:AddLine(string.format("%d / %d (%d%%)", Value - Min, Max - Min, (Value - Min) / (Max - Min) * 100), 1, 1, 1, 1, 1, 1)
  35.     GameTooltip:Show()
  36.     GameTooltip:Show()
  37. end)
  38.    
  39. ReputationBar:SetScript("OnLeave", function()
  40.     if GameTooltip:IsShown() then
  41.     GameTooltip:Hide()
  42.     end
  43. end)
  44.  
  45. ReputationBar:SetAlpha(0)
  46. ReputationBar:HookScript("OnEnter", function(self) UIFrameFadeIn(self, 1.2, self:GetAlpha(), 1) end)
  47. ReputationBar:HookScript("OnLeave", function(self) UIFrameFadeIn(self, 0.8, self:GetAlpha(), 0) end)
  48.  
  49. ReputationBarFont:SetPoint('CENTER', ReputationBar)
  50. ReputationBarFont:SetFont(AftermathhUI.media.font, 12, AftermathhUI.media.fontflag)
  51. if AftermathhUI.media.shadowoffset == true then
  52.     ReputationBarFont:SetShadowOffset(1, -1)
  53.     ReputationBarFont:SetShadowColor(0,0,0)
  54. end
  55.  
  56. local function UpdateRep()
  57.     if GetWatchedFactionInfo() then
  58.         local Name, ID, Min, Max, Value = GetWatchedFactionInfo()  
  59.    
  60.         ReputationBar:SetMinMaxValues(Min, Max)
  61.         ReputationBar:SetValue(Value)
  62.         ReputationBarFont:SetFormattedText("%d / %d - %s", Min, Max, Name)
  63.  
  64.         local FactionColors = FACTION_BAR_COLORS[ID]
  65.         ReputationBar:SetStatusBarColor(FactionColors.r, FactionColors.g, FactionColors.b)
  66.     end
  67. end
  68.  
  69. Reputation:RegisterEvent("UPDATE_FACTION")
  70. Reputation:RegisterEvent("PLAYER_ENTERING_WORLD")
  71.  
  72. Reputation:SetScript("OnEvent", UpdateRep)


or

Lua Code:
  1. if AftermathhUI.plugins.repbar == false then return end
  2.  
  3. local Reputation = CreateFrame("Frame", nil, UIParent)
  4.  
  5. local ReputationBar = CreateFrame('StatusBar', nil, UIParent)
  6.  
  7. local InvisFrame = CreateFrame("Frame", nil, ReputationBar)
  8. InvisFrame:SetFrameStrata("HIGH")
  9. InvisFrame:SetFrameLevel(5)
  10. InvisFrame:SetAllPoints()
  11.  
  12. local ReputationBarFont = InvisFrame:CreateFontString(nil, 'OVERLAY')  
  13.  
  14. ReputationBar:SetPoint('LEFT', oUF_AftermathhPlayer, 223, -178)
  15. ReputationBar:SetStatusBarTexture(AftermathhUI.media.texture)
  16. ReputationBar:SetSize(235, 20)
  17. ReputationBar:SetBackdrop({
  18.     bgFile = AftermathhUI.media.blank,
  19.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  20.     })
  21. ReputationBar:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  22.  
  23. CreateBorderLight(ReputationBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 3)
  24.    
  25. ReputationBar:SetScript("OnEnter", function(self)
  26.     if (not GetWatchedFactionInfo()) then
  27.         return
  28.     end
  29.  
  30.     local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  31.    
  32.     GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  33.     GameTooltip:AddLine(string.format("%s (%s)", Name, _G["FACTION_STANDING_LABEL" .. ID]))
  34.     GameTooltip:AddLine(string.format("%d / %d (%d%%)", Value - Min, Max - Min, (Value - Min) / (Max - Min) * 100), 1, 1, 1, 1, 1, 1)
  35.     GameTooltip:Show()
  36.     GameTooltip:Show()
  37. end)
  38.    
  39. ReputationBar:SetScript("OnLeave", function()
  40.     if GameTooltip:IsShown() then
  41.     GameTooltip:Hide()
  42.     end
  43. end)
  44.  
  45. ReputationBar:SetAlpha(0)
  46. ReputationBar:HookScript("OnEnter", function(self) UIFrameFadeIn(self, 1.2, self:GetAlpha(), 1) end)
  47. ReputationBar:HookScript("OnLeave", function(self) UIFrameFadeIn(self, 0.8, self:GetAlpha(), 0) end)
  48.  
  49. ReputationBarFont:SetPoint('CENTER', ReputationBar)
  50. ReputationBarFont:SetFont(AftermathhUI.media.font, 12, AftermathhUI.media.fontflag)
  51. if AftermathhUI.media.shadowoffset == true then
  52.     ReputationBarFont:SetShadowOffset(1, -1)
  53.     ReputationBarFont:SetShadowColor(0,0,0)
  54. end
  55.  
  56. local function UpdateRep()
  57.     if (not GetWatchedFactionInfo()) then
  58.         return
  59.     end
  60.  
  61.     local Name, ID, Min, Max, Value = GetWatchedFactionInfo()  
  62.    
  63.     ReputationBar:SetMinMaxValues(Min, Max)
  64.     ReputationBar:SetValue(Value)
  65.     ReputationBarFont:SetFormattedText("%d / %d - %s", Min, Max, Name)
  66.  
  67.     local FactionColors = FACTION_BAR_COLORS[ID]
  68.     ReputationBar:SetStatusBarColor(FactionColors.r, FactionColors.g, FactionColors.b)
  69. end
  70.  
  71. Reputation:RegisterEvent("UPDATE_FACTION")
  72. Reputation:RegisterEvent("PLAYER_ENTERING_WORLD")
  73.  
  74. Reputation:SetScript("OnEvent", UpdateRep)

Last edited by Aftermathhqt : 11-21-14 at 03:02 PM.
  Reply With Quote
11-21-14, 03:11 PM   #9
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Originally Posted by Game92 View Post
Guess it should be something like this then?
That will probably work, but you're calling GetWatchedFactionInfo twice per OnEvent/OnEnter when you only need to call it once.

I'd recommend either this:
lua Code:
  1. local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  2. if not Name then return end
  3.  
  4. -- Do watched faction stuff here

Or this:
lua Code:
  1. local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  2. if Name then
  3.     -- Do watched faction stuff here
  4. end
  Reply With Quote
11-21-14, 05:22 PM   #10
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Choonstertwo View Post
That will probably work, but you're calling GetWatchedFactionInfo twice per OnEvent/OnEnter when you only need to call it once.

I'd recommend either this:
lua Code:
  1. local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  2. if not Name then return end
  3.  
  4. -- Do watched faction stuff here

Or this:
lua Code:
  1. local Name, ID, Min, Max, Value = GetWatchedFactionInfo()
  2. if Name then
  3.     -- Do watched faction stuff here
  4. end
Works perfectly now, thanks for the help!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Reputation Bar Issue

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