Thread Tools Display Modes
08-05-13, 10:22 PM   #1
Dejaballan
A Kobold Labourer
Join Date: Aug 2013
Posts: 1
Exclamation Bartender4 Conditional

I'm trying to make a conditional which would show my bag bar only if I target my character.
[target=player, exists]show;hide doesn't seem to be working and I thought that you guys might have a clue on what to do.
  Reply With Quote
08-06-13, 02:26 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
What you want to do isn't possible using macro conditionals.

[target=player, exists] show; hide means "if the player exists, then show, otherwise hide". The "target" condition specifies the target of the macro's action, eg. /cast [target=focus] Polymorph to cast Polymorph on your focus unit.

There is no macro condition for comparing your target to a specific unit. You can only check whether the target of the macro (by default, your target, though you can use the "target" condition to specify a different target, as in the Polymorph example) is friendly or hostile, with the "help" and "harm" conditions.

You could, however, write a small, separate addon to show or hide your bag bar depending on your current target:

Code:
local state

local BagBar = Bartender4:GetModule("BagBar")

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:SetScript("OnEvent", function()
    local newstate = not not UnitIsUnit("player", "target") -- the "not not" forces it to be a boolean value
    if newstate == state then return end -- quit if the state didn't change
    state = newstate -- record the new state
    BagBar:ToggleModule(state) -- toggle the BT4 BagBar module on/off based on the new state
end)
Use http://addon.bool.no/ to turn the above code into an addon. Before downloading, click the "Show advanced (TOC) options" button and add this line in the additional box that appears, to make sure BT4 loads before your addon; otherwise you may get errors:

Code:
## Dependencies: Bartender4
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Bartender4 Conditional


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