#Using trigger variables in custom code

23 messages · Page 1 of 1 (latest)

gleaming turtle
#

So, i am trying to set up a weakaura group of buttons that i can click to (re)apply buffs to teammates. For the time being, i am just trying to get variables from triggers to work, since i haven't been able to do that. I have been trying to follow the guide from https://github-wiki-see.page/m/WeakAuras/WeakAuras2/wiki/Text-Replacements#info-from-specific-triggers

So, for example, i want to say my own character's name in chat, like this (assuming the trigger is correct):

`local playerName = aura_env.states[1].name

if not aura_env.TEST then
aura_env.TEST = CreateFrame("Button", nil, aura_env.region, "SecureActionButtonTemplate")
aura_env.TEST:SetAllPoints()
aura_env.TEST:RegisterForClicks("LeftButtonUp")
aura_env.TEST:SetAttribute("type1", "macro")
aura_env.TEST:SetAttribute("macrotext1", '/say " .. playerName)
end`

This gives errors, and i'm not sure what the problem is.

stuck pivotBOT
#

See this message #pins message for details on the perils of trying to make Auras clickable

merry cosmos
#

tldr that's not something you can do without avoiding errors, WAs is more intended for visual alerts than clickable buttons

gleaming turtle
#

compilation errors*

delicate dirge
#

no compilation is happening in a script language

gleaming turtle
#

Ok then. But it is still not working. For example, just having macro such as ''/say Hello'' does.

tough isle
#

its broken by definition.

#

there is no hope. its just broken. what you want to do isnt a thing.

gleaming turtle
#

It..is?

tough isle
#

yes.

gleaming turtle
#

I have verified it works.

tough isle
#

you said it doesnt.

gleaming turtle
#

Yes, with variables. But having a button that outputs a macro does.

tough isle
#

there are a lot of layers there, and you did the most basic of all things that barely breaks and declared it working,.

merry cosmos
#

it will break in combat no matter what you do. the whole problem is that SecureActionButtonTemplate needs the frame to remain secure/untainted, WAs constantly does things in the background during combat that will make it unsecure and cause taint, stopping it from working.

tough isle
#

i can throw a rock, so i can build a rocket.

gleaming turtle
#

I don't know if things like being in combat messes with secure frames. I would have liked to have found out myself.

My sole question was how to import text replacement. That was the core issue at hand. As i said, i have gotten a version of my code to work without the text replacement. For example, assigning any given string to the variable playerName.

barren mesa
#

There's two things to note here:

Firstly, working with SecureActionButtonTemplate (SABT) within WA has severe issues. Kolmar explained them. But to go further in depth:
As soon as the created frame is anchored to an aura region or is the child of an aura, the aura becomes protected as well. Protected status proliferates upwards. That in turn means, that any other aura anchored to it, or any group the aura is in, also becomes protected.

If you ever want to change something relevant about a protected frame in combat, Blizzard will throw errors your way and potentially brick your UI until /reload as the taint spreads.

Even if you never change the position/size/show- or hide state about the aura the SABT frame is attached to, the other auras that potentially got protected might do so and still brick your UI.
And WA also recycles regions, when that happens and the SABT is still attached to the region when it is in use by a new aura that does forbidden stuff when protected, you run into the same issues.

Even if currently you do not run into these issues, that does not mean you won't in different gameplay circumstances further down the line, or that another user won't.
You can avoid all of that through some very convoluted efforts. But it's so convoluted, that at that point you're better off simply making your desired thing as a standalone add-on.


Secondly, the amount of "dynamic" things you can do with SABT frames is severely limited by Blizzard to avoid automation of combat stuff (bot like behaviour).
You can't change which spell the button casts while in combat (besides through the options provided by blizzard, which are limited in terms of logic they allow), also not by assigning it a variable that itself might change.
It's simply not possible

merry cosmos
# gleaming turtle I don't know if things like being in combat messes with secure frames. I would h...

to answer that question specifically, you'd need to set local playerName = aura_env.states[1].name & aura_env.TEST:SetAttribute("macrotext1", '/say " .. playerName) outside of the action init block, either in custom trigger or on show or something.
aura_env.TEST should also preferably be aura_env.region.TEST to prevent the frame from multiplying (aura_env.TEST gets reset every time you open /wa options or change anything there).

#

this doesn't change that SABT shouldn't be used but thought i'd answer that

gleaming turtle
#

Ok, thanks for the information. I've seen/tried a bunch of WA's on wago.io that incorporated clickable buttons and on the surface of it they seemed to work, so that's why i figured that in principle it was possible.

barren mesa
#

Yeah it is "possible", but there are also many many people that arrive here in this discord with bricked UIs/unable to press buttons/lots of errors due to these auras from time to time.

Being baseline possible doesn't mean it works well.
WA by design and SABT frames simply don't mesh well, it is what it is.

#

As I said you can theoretically work around all those issues, but if you did that then you handle so much stuff manually through code that the purpose of WA is lost. You could've made it as a small standalone add-on at that point, with potentially less effort even.