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

Referencing commonly used token IDs without selecting or targeting the token

1621444721

Edited 1621445958
I have a character with the Inspiring Leader feat in my game. Usually, once per short rest, he’ll want to use his feat to grant himself and his party members temporary hit points.  Here is that ability: !power {{   --format|Rue  --name|Inspiring Leader  --leftsub|Feat  --rightsub|30 ft. Range  --charid|@{selected|character_id}  --emote|Rue tells [[ [TXT] 1t[Inspiring-Leader]]]. Everyone gains [[@{Rue|base_level} + @{Rue|charisma_mod}]] temp hp.  --hroll|[[ [$THP] [[@{Rue|level} + @{Rue|charisma_mod}]]d1]]  --?? @{Sun'Chu'Luk|hp_temp} < $THP.total ?? Sun Test|Passed  --?? @{Sun'Chu'Luk|hp_temp} < $THP.total ?? api_token-mod1|_ids -MYqebhy9B5EzG7Tocil _set bar1_value|[^THP] _report character|"Rue has granted {name} 7 temporary hitpoints."  --?? @{Cai'Lee|hp_temp} < $THP.total ?? Cai'Lee Test|Passed  --?? @{Cai'Lee|hp_temp} < $THP.total ?? api_token-mod|_ids -Ma4ZG3k7U7KNxZc2nKD _set bar1_value|[^THP] _report character|"Rue has granted {name} 7 temporary hitpoints."  --?? @{Charlie Adaline Murphy|hp_temp} < $THP.total ?? CAM Test|Passed  --?? @{Charlie Adaline Murphy|hp_temp} < $THP.total ?? api_token-mod|_ids -MWa_lwuw63H2BgWrmz- _set bar1_value|[^THP] _report character|"Rue has granted {name} 7 temporary hitpoints."  --?? @{Rue|hp_temp} < $THP.total ?? api_token-mod|_ids @{selected|token_id} _set bar1_value|[^THP] _report character|"Rue has granted {name} 7 temporary hitpoints."  --?? @{Galahad|hp_temp} < $THP.total ?? api_token-mod|_ids -Ma4ZOMBh-H2VLvppVh4 _set bar1_value|[^THP] _report character|"Rue has granted {name} 7 temporary hitpoints."  --Temporary Hitpoints Added:|[^THP]  --!format-|~~~  --Description|  --!^1Desc|You can spend 10 minutes inspiring your companions, shoring up their resolve to fight. When you do so, choose up to six friendly creatures (which can include yourself) within 30 feet of you who can see or hear you and who can understand you. Each creature can gain temporary hit points equal to your level + your Charisma modifier ([[@{Rue|level} + @{Rue|charisma_mod}]]). A creature can't gain temporary hit points from this feat again until it has finished a short or long rest. }} In this macro, I use PowerCards to check if the character already has a number of temporary hit points that is greater than or equal to the amount of temporary hit points that my inspiring leader will grant. To apply these temp hps, I use token mod. Here’s the rub: he will be casting this relatively often. As a matter of convenience, I’d like to avoid making him select 4+ targets when he uses this feat so that I can collect that token’s ID. But token ids change, and I don’t think it’s possible to reference a character’s token ID by typing @{Name|token_id}   Am I going to just have to bite the bullet and have him select his targets manually?
1621445928
The Aaron
Roll20 Production Team
API Scripter
I don't know if it helps, but TokenMod can select tokens by character id, so if you can reformat the change to happen via it, you could get it to work. 
That does help! Why didn't I think of that! Thanks, man. That answers my question.
1621446565
timmaugh
Forum Champion
API Scripter
You can use SelectManager and the {& select} formation. {& select Bob the Hirsute, Coriander the Spicy, Captain FluffyPants} {& select} will replace any tokens currently selected (basically starting as if nothing were selected). If, on the other hand, you want to *add* to the selected tokens, you can do the same thing with {& inject} . Or, if you don't want to have it always hard-coded to the same characters, you can use another metascript, Muler , to maintain a list of characters to target for any given situation, then resolve which set to select in a roll query. The below example uses the ZeroFrame loop to control the order (making sure the muled variable resolves before the virtual selection takes place): {\& select get.?{Which set of selected?|The Party,theParty|Party plus Dookie,thePartyD}/get}{& mule Selectables} That would look for and load a Mule called "Selectables", then go look for a variable named either "theParty" or "thePartyD", depending on how the user answered the roll query and what was left behind in the command line. The Muled variable would be the list of tokens to select, which Muler returns to the line. Finally ZeroFrame will un-escape the {\& select....} to be {& select...} , which makes it detectable by the SelectManager script. By this point, your roll query has turned into a list of tokens to select, chosen specifically for this casting of the spell. The following line is an equivalent alternative, except that instead of deferring the detection of the {& select ... } construction, it simply orders the scripts to run in the order we need: {& select get.?{Which set of selected?|The Party,theParty|Party plus Dookie,thePartyD}/get}{& mule Selectables}{& 0 get sm} If you want to explore more of what these scripts can do, they are part of the meta toolbox .