#Slightly improved macro
1 messages ยท Page 1 of 1 (latest)
Yours works as is, but this is a slightly cleaned up version of the macro. Biggest difference is that it now uses your command variable instead of ignoring it.
/*- DOCUMENTATION -*/
// Duplicate and change this macro name to the button title
// set targetMacro below to target i.e. targetMacro = 'applyBuff'
// set commandOverride below to ignore the title and use the command instead
/*- CONFIGURATION -*/
const targetMacro = 'applyBuff';
const commandOverride = '';
/*- COMMAND -*/
const command = commandOverride || this.name;
if (typeof shared !== 'undefined') event.args = arguments;
window.macroChain = [command, ...(window.macroChain ?? [])];
game.macros.getName(targetMacro)?.execute({ actor, token });
(it won't make any difference for the problem you're having with unlinked tokens)
It looks like you're using it in a script call, is that correct?
yes. as use
@native field โ๏ธ that last bit could be relevant
Can you try it with a macro button in the chat card on an unlinked token and see if that works for you? If it does, then it's how the macro is fetching data from the macro chain
myself wont work with manual call either
macro button as macro{etc} ?
So if you do @Macro[applyBuff]{Apply Mage Armor on myself at 7} as text within the description for the Brooch of Shielding, same thing happens (or rather same thing doesn't happen)?
it works like that
@native field That's the problem then
Replace that last line with this, update the name to target instead of myself and see if that works
await game.user.updateTokenTargets([token.id]);
game.macros.getName(targetMacro)?.execute({ actor, token });
This will clear out the user's current targets, but that should be fine since you're not in the middle of an attack
Hopefully this is an acceptable workaround
You might have to export the token Hevka. It's still working as a script call on my end too
Are you on V11 or V10?
Gotcha. Found the problem Did not find the problem, just something else. Is the player clicking this the GM? Do they have a Player Character assigned to them?
Can you double check there's only a single instance of applyBuff and it is the latest version copied from gitlab? (the auto-updater may have broken?)
v10. GM click. latest single macro of applyBuff.
any unlinked token share the same issue
thats the actor
or do you need the token on the canvas? i dont really know how to export them from that point
I imported that actor, gave her Mage Armor spell back and then clicked it from the canvas and it worked
very strange...
Oh. I got it to break
Nice
It is of course: a race condition ๐ orz
Unfortunately, it requires an update to the calling script (script calls)
I don't have the infrastructure for a migration...
The order SHOULD be item/spell is used -> buffs apply -> active effect is generated -> usage slot is consumed
It is generating a random order for the remaining three because they're all happening at the same time. It is showing up now because base pf1e has shifted the timing in a way that unlinked tokens are more likely to be out of order now.
In short,
- Update script calls to have an
awaitin front of the last line (this was not possible back when I wrote callMacro) - Update applyBuff to wait on everything before reporting it is done (this was not possible back when I wrote applyBuff)
The simplified script call snippet
window.macroChain = [this.name];
event.args = arguments;
await game.macros.getName("applyBuff")?.execute({ actor, token });
is correct.
This is such a devastating bug I think I have to bite the bullet and update Force Update All...
Yup. Need to make a module. That was the inflection point where these macros have gotten unwieldy enough that they shouldn't be handled via macros anymore.
It's just punishing people for using them. It was fine when they were being exclusively called through clicking content-links but with having to duplicate code because of script calls, there's too much room for bit-rot without a safe way for me to update
im not really clear on what parts of applyBuff should now contain await
ScriptCalls part is clear
Yeah, I haven't updated applyBuff yet. Or rather, I haven't pushed the update. Soon though
Thanks.
Btw By module you meant compendium with macroses or something else?
it would be wild even if it just adds "template" for actions to deal with applybuff without copy/paste bunch of text ๐
Yeah, something like that. It comes down to I shouldn't force people to have to write and maintain dozens of instances of code.
It was fine when the code was "Apply Mage Armor to myself" because that's probably not going to change.
But now that js script calls and macros can become out of date it would ideal to have an API.
ApplyBuff("Apply Mage Armor to myself");
(Not actually what it will be. I still have to design it)
If you're going to make a mod can you include a world setting for "don't require GM middle-man handling"?
Yeah. It'll be a GM-only setting though
(as in, the GM will have to turn on the setting)
Yeah that's what I'd expect ๐