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

Using TokenMod to update multiple tokens' bars (with HP is broken)

For years I've been using the following script on single tokens to (re)set them up in a rerunnable 5e dungeon: !token-mod {{ --on showname showplayers_name showplayers_bar1 --set bar3_value|@{selected|npc_speed} bar2_value|@{selected|npc_ac} bar1|[[@{selected|npc_hpformula}]] statusmarkers|-dead bar_location|overlap_top }} I'm now trying to use @timmaugh's recommended  TokenMod + SelectManager + Fetch + ZeroFrame for handling this Token Mod script to process it on multiple tokens at once but am running into an issue !forselected(^) token-mod {{ --on showname showplayers_name showplayers_bar1 --set bar3_value|@^(selected.npc_speed) bar2_value|@^(selected.npc_ac) bar1|@^(selected|npc_hpformula) statusmarkers|-dead bar_location|overlap_top }} Bar1 max and Bar1 current becomes the HP formula from the tokens' character sheet(s). Any ideas or thoughts on appropriately setting up Bar 1 with current and max HP as a roll of the formula? TYIA
1698198541
timmaugh
Forum Champion
API Scripter
Hey, ApolloNik... here's how you'd make that work. You'd need to use a deferred roll to have it execute the formula. You would want the roll deferred until both 1) the outbound message was sent (the iterated message for each token), and 2) during that outbound message Fetch had a chance to resolve getting the formula from the sheet. That would require both a SelectManager deferral (to satisfy #1), and a ZeroFrame deferral (to satisfy #2). Note, nothing in your command line should trigger ZeroFrame to take a loop during the initial message -- the one that will eventually land with the forselected handle of SelectManager, and which will subsequently dispatch all of the outbound messages. Since there would be no second pass of ZeroFrame, there would be no un-deferral during this message... meaning that a single ZeroFrame deferral for the solution we're about to apply would survive until we need it (surviving into each dispatched message). If that were to change, so that ZeroFrame needed to take a loop during the initial message, we would need to increase our ZF deferral count by one. Again, we don't have to do that at this point... one ZF deferral should work (along with a forselected deferral. That would look like this: !forselected(^) token-mod {{ --on showname showplayers_name showplayers_bar1 --set bar3_value|@^(selected.npc_speed) bar2_value|@^(selected.npc_ac) bar1|[^\][^\]@^(selected|npc_hpformula)\^]\^] statusmarkers|-dead bar_location|overlap_top }}
Ty so much Timmaugh! This is incredibly helpful.