#Slightly improved macro

1 messages ยท Page 1 of 1 (latest)

lunar sail
#

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?

tender vigil
#

yes. as use

lunar sail
#

@native field โ˜๏ธ that last bit could be relevant

tender vigil
#

it does work with selected/targets selector though

#

only myself seems bugged

lunar sail
#

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

tender vigil
#

myself wont work with manual call either

lunar sail
#

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)?

lunar sail
#

@native field That's the problem then

tender vigil
#

it wont work with Call macro with targets of myself

#

unless token is linked

lunar sail
#

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

native field
#

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?)

tender vigil
#

thats the actor

#

or do you need the token on the canvas? i dont really know how to export them from that point

native field
#

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

native field
#

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,

  1. Update script calls to have an await in front of the last line (this was not possible back when I wrote callMacro)
  2. 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...

native field
#

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

tender vigil
#

ScriptCalls part is clear

native field
#

Yeah, I haven't updated applyBuff yet. Or rather, I haven't pushed the update. Soon though

tender vigil
#

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 ๐Ÿ™‚

native field
#

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)

lunar sail
#

If you're going to make a mod can you include a world setting for "don't require GM middle-man handling"?

native field
#

Yeah. It'll be a GM-only setting though

#

(as in, the GM will have to turn on the setting)

lunar sail
#

Yeah that's what I'd expect ๐Ÿ‘

native field
#

Force Update All now can get its own updates. I have made a dog that can pet itself.

#

Alright, those are all pushed Hevka.
applyBuff, callMacro, Force Update All, and Update Old callMacro