View Single Post
01-11-16, 07:19 PM   #10
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by SDPhantom View Post
My guess is you're trying to swap the artwork before the game as officially applied the changes between vehicle and player modes. Have you tried limiting all the visual stuff to UNIT_ENTERED_VEHICLE and UNIT_EXITED_VEHICLE? From what I can tell, the UNIT_*ING_VEHICLE events trigger hiding the old UI and UNIT_*ED_VEHICLE events trigger showing the new one. At least that's how the default UI handles it.

Also, if you're using the SecureStateDriver system, they don't necessarily listen to these events and are delayed by at least 200ms. You might be able to hook into the OnAttributeChanged script to act on when RegisterUnitWatch() triggers. If you leave it to show/hide the frame itself, it changes the statehidden attribute to a true/nil value.



At this point, I'm just running off a list of what could be going on. I don't see what self:UpdateDisplay() is doing or how unit switching is being handled not only from the artwork aspect, but how the SecureUnitButton template is being used. All that's being shown is debug code that isn't really going to work in the end product.
My secure state looks like this:

Lua Code:
  1. self.frame.state = CreateFrame("Frame", nil, nil, "SecureHandlerStateTemplate")
  2.     self.frame.state:SetFrameRef("ZPerlPlayerPet", self.frame)
  3.     self.frame.state:SetAttribute("_onstate-vehicleupdate", [[
  4.         --print(newstate)
  5.         if newstate == "invehicle" then
  6.             self:GetFrameRef("ZPerlPlayerPet"):SetAttribute("unit", "player")
  7.         else
  8.             self:GetFrameRef("ZPerlPlayerPet"):SetAttribute("unit", "pet")
  9.         end
  10.     ]])
  11.     RegisterStateDriver(self.frame.state, "vehicleupdate", "[vehicleui] invehicle; none")

By default i only use the *ED events but thats when the issue happens, thats why i added the *ING events to hide the frame between them.

The UpdateDisplay() funtion is noting special just updates the frame, name level buffs etc. Also my SecureUnitButton has nothing special it's using the RegisterUnitWatch method.

The whole code:

https://github.com/Resike/Z-Perl2/bl.../PlayerPet.lua
  Reply With Quote