WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   PlayerModel:GetModel() bug (https://www.wowinterface.com/forums/showthread.php?t=13160)

Macniel 10-28-07 07:38 AM

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 ?

Teif 11-22-07 07:28 AM

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.


All times are GMT -6. The time now is 08:26 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI