View Single Post
01-20-18, 06:11 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
visibility state driver on unitframes?

Hi guys,

I tried adding a visibility state driver to my player unitframe.
I cannot get it to work.

Lua Code:
  1. --show/hide the frame on a given state driver
  2.   if cfg.frameVisibility then
  3.     frame.frameVisibility = cfg.frameVisibility
  4.     frame.frameVisibilityFunc = cfg.frameVisibilityFunc
  5.     RegisterStateDriver(frame, cfg.frameVisibilityFunc or "visibility", cfg.frameVisibility)
  6.   end

What am I missing?

Wierdly enough if I enter /run oUF_SimplePlayer:Hide() into chat it pops right back up.

I use the following modifier on my actionbar which works just fine:

Lua Code:
  1. frameVisibility = "[combat][modifier][@target,exists] show; hide"

How do I register a custom visibility state driver on oUF unit frames?

I tried adding a seperate state handler frame. The handler is working properly. The show/hide has an effect according to the chat output but the visual effect is not there. The player frame stays visible.

Lua Code:
  1. --show/hide player frame on state change
  2.   local player = oUF:Spawn("player", A.."Player")
  3.   local frame = CreateFrame("frame",nil,nil,"SecureHandlerStateTemplate")
  4.   frame:SetFrameRef("player", player)
  5.   frame:SetAttribute("_onstate-combat", [=[
  6.     player = self:GetFrameRef("player")
  7.     print(newstate,player:GetName())
  8.     if newstate == "show" then
  9.       player:Show()
  10.       print(player:IsShown())
  11.     else
  12.       player:Hide()
  13.       print(player:IsShown())
  14.     end
  15.   ]=])
  16.   RegisterStateDriver(frame, "combat", "[target,exists][modifier] show; hide")

I added this:

Lua Code:
  1. hooksecurefunc(player, 'Show', function(self)
  2.     print("func call Show",self:GetName(),self:IsShown())
  3.   end)

It literally spams my chat with Show calls. What the heck is going on? The same is true for target if I have a target and the hook is applied to target aswell.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 01-20-18 at 07:31 AM.
  Reply With Quote