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

API Script for Rolling/Speaking as selected token?

Hello everyone!

I'm running Curse of Strahd on 5E and there are about 150 monsters to scroll through when selecting who to "speak" as. I'd like for the chat to display the token icon/name of what individual monster is attacking when I click their attack from their character sheet. I've looked through mods that sort of do what I want, but it involves creating all sorts of buttons.

Does anyone have any ideas?

August 01 (2 years ago)

Edited August 01 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Sounds like something that could be done leveraging two scripts together (maybe this script and On My Turn) and then gluing them with a metascript. 

My guess is that you could set On My Turn to run the "speaking as" command when they come to the top of the turn order, using a metascript to virtually select the top token.

I'll summon the Metamancer.

August 01 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Actually, I just looked at OnMyTurn, and it handles the selection on its own. No metascript needed, but it would require adding an Ability to each character.

August 01 (2 years ago)
timmaugh
Forum Champion
API Scripter

"You do plan to have... metamancers... on  your... metamancer tour, right?"

=D

There are a couple of metascript tools that could help, depending on how you want to proceed. For instance, Fetch has a formation to get information from the tokens in the tracker. You'd probably be interested only in the current-turn's token, so retrieving that token's name (for instance) would look like:

@(tracker.token_name)

Keith mentioned a script that changes your "Speaking As..." value. That script uses the character ID. So you could use a Fetch formation to get the character ID from the current turn:

@(tracker.character_id)

You could have a single ability macro (which I, personally, would put in my button bar) that would fire the script using that formation:

!switch @(tracker.character_id)

The way Fetch constructions work, if there wasn't a character id associated with the token, that would return blank, and the macro would revert to you (the player/gm). You could have another ability macro that simply reset the Speaking As -- not using a fetch construction at all.

Extended Application

If you have a bunch of mooks pulling from the same sheet, you might find that the "Speaking As" differentiation isn't enough... if you have 10 goblins attacking, it doesn't help to differentiate them by calling them all "Goblin". In that case, you could have the tokens individually named, and pull the current turn's token's name like this:

@(tracker.token_name)

You can really quickly rename a bunch of tokens using SelectManager and TokenMod... select the tokens and run:

!forselected token-mod --set name|MookNameHere{&i}

If you swapped out "MookNameHere" with "Goblin", you could have Goblin0, Goblin1, Goblin2, etc. Having individually named tokens could get around the differentiation problem... but it would change your workflow. Instead of changing your Speaking As value, you'd just reference the current token's name (as shown above).

August 04 (2 years ago)

Thank you so much for your replies! I appreciate the help. =)  I will try both methods.