First I'm apologise if "Addon Help" would be the better subforum, but because Stuf Unit Frames didn't provide the features I want and I have some general questions too, I choose "Lua Code Discussion".
I want to archive that the PlayerFrame provided by Stuf Unit Frames hides when I'm
- at 100% Health
- have no target
- out of combat
- not mouseover it
and that the TargetTargets(?) Frame hides when
- I'm the target
Because I have no experience in LUA or creating an WoW Addon I googled and found this thread LUA: Hide unit frames out of combat.
With the Information and LUA Snippet in that thread and the rest i found via google i created this code:
local hideAnything = CreateFrame("FRAME", nil, nil, "SecureHandlerStateTemplate") hideAnything:RegisterEvent("PLAYER_ENTERING_WORLD"); local function HideFrame(self) -- Insecurely hide out of combat if shown if not InCombatLockdown() then self:Hide() end end local function eventHandler(self, event, ...) if (IsAddOnLoaded("Stuf")) then hideAnything:SetFrameRef("PlayerFrame", Stuf.units.player) Stuf.units.player:HookScript("OnShow", HideFrame) end hideAnything:SetAttribute("_onstate-combat", [=[ -- Securely toggle visibility in combat if newstate == "show" then self:GetFrameRef("PlayerFrame"):Show() else self:GetFrameRef("PlayerFrame"):Hide() end ]=]) RegisterStateDriver(hideAnything, "combat", "[combat] show; hide") end hideAnything:SetScript("OnEvent", eventHandler)
The code works but only in combat and I didn't found a solution for my "out of combat" problems.
Also in the linked thread i found that i could only use this:
RegisterStateDriver(PlayerFrame, "visibility", "[combat] show; hide") RegisterStateDriver(TargetFrame, "visibility", "[combat,exists] show; hide") RegisterStateDriver(ComboFrame, "visibility", "[combat,exists] show; hide") RegisterStateDriver(FocusFrame, "visibility", "[@focus,combat,exists] show; hide")
I modifed that to my parameters I use in bartender
RegisterStateDriver(hideAnything, 'visibility', '[combat] show; hide') RegisterStateDriver(hideAnything, 'visibility', '[target=vehicle,exists]hide') RegisterStateDriver(hideAnything, 'visibility', '[vehicleui]hide;show') RegisterStateDriver(hideAnything, 'visibility', '[target=target, exists]show;fade:0')
... it didn't worked at all :(
- I work in the "PLAYER_ENTERING_WORLD" Event because I couldn't find a solution how I execute my Code AFTER Stuf Unit Frames loaded and the frames I access aren't nil anymore. Is there a better way?
- In the SetAttribute Method is the state(?) "_onstate-combat" used, but I didn't find ANY HELPFUL documentation about this state. wowprogramming.com refers to SecureTemplateReference, but "_onstate-combat" isn't listet there.
Questions to my Problem:
- How do I accomplish the tasks I want?
I appreciate any tips and hints and would prefer them, because i would like to accomplish this mostly by myself, but I woudln't mind a complete solution.
Hope someone can help me.
English isn't my native language, so I hope it isn't to awfull to read / understand