Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Macro commands and script command order-of-operations

June 13 (1 month ago)

Edited June 13 (1 month ago)

So, I'm trying to create a macro that switches to an NPC avatar, emotes and speaks to chat, and then switches back to the GM.  I have nearly exactly what I want, but I have one hurdle.  Here is the macro:

!switch -OS0m6Rm0TdCoo7dGM0o
/em is suddenly still and sadness seeps from her. %NEWLINE% ["This was where I… no. I'm not here anymore.... Then they’ve taken the remains below. For the ritual."](!:)
!switch

It produces exactly what I want (if I use the workaround):

The hurdle is that it executes the bang commands after the emote so it doesn't switch to the NPC avatar before the emote.  I imagine that chat input (chat commands and content vs API calls) is parsed in a particular order and likely asynchronously.  I can live with this (using another button to do the switch manually), but I'm trying to see if there is a way to force the behavior I want.  I am aware of !dialog, !emas, and !ColorEmote.  None of those produce what I want visually.  I'm guessing what I might need to do is find a way to turn the /em line into a !command with basically no additional functional behavior.  Thoughts? Sorry if this is the wrong forum.

June 14 (1 month ago)
Andrew R.
Pro
Sheet Author

Yes, all the Roll20 parser stuff happens first.

The MetaScript Toolbox might be able to help you force things to happen in the right order by deferring the “/em”.

June 14 (1 month ago)

Edited June 14 (1 month ago)

I love complex systems.  Sooooo... there's a boatload in that toolbox, but I tried the one thing that seemed to come up that matched my issue. Thank you for giving me that pointer.  

!switch -MSIyjbZdcs-GV8KNCh4
!/em is suddenly still and sadness seeps from her. %NEWLINE% ["This was where I… no. I'm not here anymore.... Then they’ve taken the remains below. For the ritual."](!:) {& simple}
!switch

Good news: it puts things in the right order.

Bad news: the first !switch doesn't actually execute (fixed), the /em passed through the API uses the player avatar, not the active one, AND it puts the output of the em and the non-em (after the NEWLINE) on separate lines/entries. 

I'll keep fiddling unless someone comes along with a more targeted suggestion.

June 14 (1 month ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Commissioner Keith calmly walks to the top of Roll20 Headquarters in downtown Gotham and flips the switch on the Metamancer Signal...




June 14 (1 month ago)

It's been a while since I've been in the forums, but I don't remember them ever being this... cinematic. Love it!

June 14 (1 month ago)
timmaugh
Forum Champion
API Scripter

*lowers in via meta-grapple*

*misjudges and goes through the floor, straight into the next post*

June 14 (1 month ago)
timmaugh
Forum Champion
API Scripter

*strikes heroic pose that drives all memories of falling through the floor out of bystander memories*

...

*I said all memories*

OK, try this... Not in a place where I can test, but if it doesn't work I might be able to look at it more tomorrow.

The first version is definitely a race condition where the unprocessed /em line is hitting the chat first. In the later formulation, you are at least slowing down the /em line by starting it as a script command... but I think it has already started by the time the first command resolves... so it has the first associated avatar (rather than the later).

I'm not convinced this is going to work for the same reason (behind the scenes, the Toolbox is keeping track of who sent the overall message, then returning that information to all sub-messages), but give it a shot:

!{{

!switch -MSIyjbZdcs-GV8KNCh4

/em is suddenly still and sadness seeps from her. %NEWLINE% ["This was where I… no. I'm not here anymore.... Then they’ve taken the remains below. For the ritual."](!:)

!switch

}}

If it doesn't work, we might need to add a new syntax token to the Toolbox to let you alter who you are sending as. I'll have to think through the timing of that to make sure it would work, but if it does work you might be able to get away from having to use the !switch command, altogether.

June 14 (1 month ago)

Ok, that was an epic response.  I wish the result matched it. :)

Please only work on this if it interests you--I can get hyperfocused with the best of them and that's why I wanted to perfect it, but I have a work around.