View Single Post
06-15-10, 04:20 PM   #16
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
got a problem... i think.

so if i use the self in a function that is responding to events and the function is only used in the onevent script of a frame that is outside the initial frame creation code.... it wont recognize self as the party frames right? the partyframe has to run the code somehow?

like i fixed the name coloring code to read as follows i think this is how it should be set up per everyone's instructions ill do my best to show it here in proper order...

so here is the name coloring code
lua Code:
  1. function GrimUI:PartyNameColoring(self)
  2.    
  3.  
  4.     if UnitExists(self.unit) == 1 then
  5.          self.InfoTextFrame.NameText:SetFormattedText("%s", UnitName(self.unit))
  6.     end
  7.    
  8.    
  9.     if event == "PLAYER_ENTERING_WORLD" then
  10.         if UnitThreatSituation(self.unit) == nil then
  11.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  12.         else
  13.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  14.         end
  15.        
  16.         if UnitAffectingCombat(self,unit) == nil then
  17.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  18.         else
  19.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  20.         end
  21.    
  22.     end
  23.    
  24.     if event == "UNIT_FLAGS" then
  25.         if UnitThreatSituation(self.unit) == nil then
  26.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  27.         else
  28.        
  29.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  30.         end
  31.        
  32.         if UnitAffectingCombat(self,unit) == nil then
  33.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  34.         else
  35.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  36.         end
  37.     end
  38.    
  39.     if event == "UNIT_THREAT_LIST_UPDATE" then
  40.         if UnitThreatSituation(self.unit) == nil then
  41.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  42.         else
  43.        
  44.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  45.         end
  46.         if UnitAffectingCombat(self,unit) == nil then
  47.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  48.         else
  49.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  50.         end
  51.    
  52.     end
  53.    
  54.     if event == "UNIT_THREAT_SITUATION_UPDATE" then
  55.         if UnitThreatSituation(self.unit) == nil then
  56.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  57.         else
  58.        
  59.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  60.         end
  61.         if UnitAffectingCombat(self,unit) == nil then
  62.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  63.         else
  64.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  65.         end
  66.    
  67.     end
  68.  
  69.     if event == "UNIT_COMBAT" then
  70.         if UnitThreatSituation(self.unit) == nil then
  71.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  72.         else
  73.        
  74.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  75.         end
  76.         if UnitAffectingCombat(self,unit) == nil then
  77.         self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  78.         else
  79.         self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  80.         end
  81.     end
  82. end

now here is the function thats been made to call it

lua Code:
  1. function GrimUI.PartyNameTextEvents(self)
  2.     if UnitExists(self.unit) == 1 then
  3.         self.NameText:SetFormattedText("%s", UnitName(self.unit))
  4.     end
  5.     self:PartyNameColoring()
  6. end

now here is what calls that function

lua Code:
  1. GUINameTextEvents:SetScript("OnEvent", function()
  2.     GrimUI.PartyNameTextEvents()
  3. end)

now here is ultimately where i think the big mistake is and maybe it is as easy as parenting the event frames to the party frames in some way? or adding them to the frame creation part? im not sure how that would go... but here is what it is currently, clearly it has no link with the partyframes themselves other then to initiate the event scripts

lua Code:
  1. local GUINameTextEvents = CreateFrame("Frame", nil, UIParent)
  2. GUINameTextEvents:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. GUINameTextEvents:RegisterEvent("PARTY_MEMBERS_CHANGED")
  4. GUINameTextEvents:RegisterEvent("UNIT_NAME_UPDATE")
  5. GUINameTextEvents:RegisterEvent("UNIT_FLAGS")
  6. GUINameTextEvents:RegisterEvent("UNIT_THREAT_LIST_UPDATE")
  7. GUINameTextEvents:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
  8. GUINameTextEvents:RegisterEvent("UNIT_COMBAT")
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote