Thread Tools Display Modes
10-28-07, 07:38 AM   #1
Macniel
A Fallenroot Satyr
 
Macniel's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 26
PlayerModel:GetModel() bug

Hello, I am developing a new Addon which uses the Widget PlayerModel to display the Current Target Player in 3D Mode. But there is one big problem which I try to fix but it doesn't work

my first attempt was to PlayerModel:SetUnit("target") on every Onupdate - okay this works, the Model change to every Target but the ModelSequence Loop starts with every OnUpdate Cycle and this doesn't look very nice.

my second attempt was to lock the UnitModel, this works but the TargetModel won't update.

my third attempt was to check the filepath of the PlayerModel with GetModel() but there is my Bug.

If no Modelfile is set it returns the Object itself if a Modelfile is set it returns the Filepath (as it should) But, how can i query the PlayerModel if it has a valid File ?
  Reply With Quote
11-22-07, 07:28 AM   #2
Teif
A Deviate Faerie Dragon
Join Date: May 2006
Posts: 12
One thing you can do instead of using the OnUpdate method is to register the event PLAYER_TARGET_CHANGED with your AddOn. This event will trigger everytime your target changes, also when your target is lost.

you can then do a check for a target when this event is fired, and if a target exists, do the update.

Code:
function MyAddOn_OnEvent(frame, event, ...)
   if (event == "PLAYER_TARGET_CHANGED") then
      if (UnitExists("target")) then
        
         -- The event has been triggered, and we have a target
         -- update your PlayerModel instance here

         PlayerModel:SetUnit("target");
      else
    
         -- do whatever you wanted to do when there's no target
         -- (hiding the frame, showing an empty window, etc) ...

      end
   end
end
Hope this helps.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » PlayerModel:GetModel() bug


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