View Single Post
02-16-13, 11:41 PM   #2
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Originally Posted by Spyro View Post
Hi guyz.
Lua Code:
  1. local function GetThreatRegion(Plate)
  2.   return select(1, (Plate:GetChildren()):GetRegions())
  3. end
  4.  
  5. TheNameplate:SetScript("OnShow", function(Plate)
  6.   GetThreatRegion(Plate):SetVertexColor(0, 1, 0, 1)
  7.   GetThreatRegion(Plate):Show()
  8. )
What are you passing to 'GetThreatRegion()'?

If 'TheNameplate' is a stock UI nameplate, is SetScript not a bit dangerous? HookScript does the same as SetScript if no function already exists for the handler in question with the added bonus of not inadvertently removing the script set by Blizz (or another addon). If it's your own nameplate, sorry for misunderstanding.

In your example, is 'TheNameplate' the same object as 'Plate'? If so...

Lua Code:
  1. local nameplate = ?;
  2.  
  3. nameplate:HookScript("OnShow", function(self)
  4.     GetThreatRegion(self):SetVertexColor(0, 1, 0, 1);
  5.     GetThreatRegion(self):Show();
  6. )


If it were me, I'd use print to test the code to make sure you're on the right track. Notably, I'd definitely check the return value of GetThreatRegion().

Lua Code:
  1. print( select( 1, (nameOfNameplate:GetChildren()):GetRegions() ) );

I'm not sure, but using the first return from GetRegions (from the first return of GetChildren) seems a bit off.
__________________
__________________

Last edited by Aanson : 02-16-13 at 11:55 PM.
  Reply With Quote