Hide custom buttons on combat

Greetings, let me share some context.

I’m a pretty clueless player. As I wonder trhough Shadowlands with my [Crusader Aura] up, I fight against a bunch of badies and at the end of the combat I realize that I’ve forgot to put had my [Devotion Aura] all combat long.

I’ve created an AddOn in order to avoid this issue, it shows on screen the icon of the aura that I should be using, it follows the logic below:

if (IsMounted()) then 
	if (not Is_Up("Crusader Aura", "player")) then
		Set_Icon("Crusader Aura", "player");
	end
else
	if (Is_Up("Crusader Aura", "player")) then
		Set_Icon("Devotion Aura", "player");
	end
end

Is_Up function checks if the unit identified by the second parameter have the buff identified by the first parameter, returning true if so…

Set_Icon function shows the icon of the aura that should be used (first parameter), this is the code:

local function Set_Icon(buff, target)
	if (buff ~= nil) then
		ImClueless_Button_Icon:SetTexture(GetSpellTexture(buff));
		ImClueless_Button:SetAttribute("type", "spell");
		ImClueless_Button:SetAttribute("spell", buff);
		ImClueless_Button:SetAttribute("unit", target);
		ImClueless_Button:Show();
	else
		ImClueless_Button:Hide();
	end
end

It works like a charm out of combat, in combat is another story: As I wonder trhough Shadowlands with my [Crusader Aura] up, I fight against a bunch of badies and my AddOn icon doesn’t change until I’m out of combat.

I know that the secure code and tainting is interferring with the icon update, but I also know that there’s some workaround -I’ve seen other AddOns hiding things on combat- does anyone know how to make this work?

As reference, I’ll paste below the templates I’m using:

<Ui>
	<Frame name="ImClueless_Warning" inherits="SecureHandlerStateTemplate" parent="UIParent" protected="true">
		<Size x="64" y="64"/>
		<Anchors>
			<Anchor point="TOP" y="-128"/>
		</Anchors>
		<Frames>
			<Button parent="UIParent" inherits="SecureActionButtonTemplate" name="ImClueless_Button">
				<Size x="64" y="64"/>
				<Anchors>
					<Anchor point="TOP" y="-128"/>
				</Anchors>
				<Layers>
					<Layer level="OVERLAY">
						<Texture name="$parent_Icon" setAllPoints="true" file="Interface\Icons\Spell_Nature_Regeneration"/>
					</Layer>
				</Layers>
			</Button>
		</Frames>
		<Scripts>
			<OnLoad>
				self:RegisterEvent("PLAYER_ENTERING_WORLD");
				self:RegisterEvent("PLAYER_REGEN_DISABLED");
				self:RegisterEvent("PLAYER_REGEN_ENABLED");
				self:RegisterEvent("UNIT_AURA");
				self:RegisterEvent("COMPANION_UPDATE");
				self:RegisterEvent("SPELL_UPDATE_COOLDOWN");
			</OnLoad>
			<OnEvent function="ImClueless_Event"/>
		</Scripts>
	</Frame>
</Ui>

Thanks a lot!

Are you trying to do this as a learning exercise? You could probably whip this up as a weakaura in about 30s.

I’m doing it not as a learning exercise (I’m learning a lot though) but because I want to do this myself.

Cool, one of the regulars who are adept in that area should be able to help you :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.