Unsheathe weapons when casting stealth

I am trying to make a macro to unsheathe my weapons of they aren’t already and cast stealth.

Because toggleSheath() needs /run to work, how can I make this work?

1 Like

Something like this should work

#showtooltip
/run if GetSheathState() == 1 then ToggleSheath() end
/cast !Stealth

Remove the ! if you rather want it to toggle Stealth

1 Like

This works great, thanks!

Is there a way to nest if statements? I am looking to draw weapons going into stealth and sheath them when leaving stealth.

I am doing pseudo code here, as I do not know LUA:

if (noStealth) {
    if (GetSheathState() == 0) {
        ToggleSheath()
    }
} else {
    if (GetSheathState() == 1) {
        ToggleSheath()
    }
}
/cast Stealth

I am probably overthinking this, but this should work (with logic explained)

if stealth then --> unstealthing
	if not sheathed then
		ToggleSheath() -- sheath
	end
else --> stealthing
	if sheathed then
		ToggleSheath() -- unsheath
	end
end

/cast Stealth
-- Karnaugh map
A = stealth
B = sheath

B/A   0   1
  0   0   1
  1   1   0
#showtooltip
/run if IsStealthed() ~= (GetSheathState() == 1) then ToggleSheath() end
/cast Stealth

There also is https://www.curseforge.com/wow/addons/autosheath if that works for you

1 Like

It works perfectly! Thanks so much.

1 Like

I shortened it a bit, forgot https://wow.gamepedia.com/API_IsStealthed was a thing… and fixed it again

1 Like