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

Simple Macro for population token bar values??????

1687462381

Edited 1687506491
Hi folks I wonder if one of you macro guru's can help me. I need a simple macro that can be assigned as a token bar button that populates the basic values of speed, AC and Hit Points into the token bar without linking.  E.G.  I create a token, assign the token as a bandit and simply need to press a button to populate those numerical values from the stat block.   Is that possible? Cheers
That's something that works best with the TokenMod script 
1687483336

Edited 1687638417
timmaugh
Forum Champion
API Scripter
Hey, Mike... you'll want TokenMod to accomplish that. Assuming you want: bar1 = speed bar2 = AC bar3 = HP ...the command would be: !token-mod --set bar1|@{selected|speed}|@{selected|speed} bar2|@{selected|AC}|@{selected|AC} bar3|@{selected|HP}|@{selected|HP} Obviously change the bar positions for the stats as you prefer, and make sure that I used the correct name of the attributes. Note that I used each twice so that the second instance would set the max value of the bar, giving you the bars, not just the bubbles. Also I used the fully qualified @{selected|...} form so that you could abstract this to a Macro Mule character (or a Collection tab macro, but those are ugly) instead of having to add it to each such character sheet that might spawn mooks. Now. Let's get funky. You want to get nuts? Let's get nuts. What if you spawned 5 bandit mooks, and you wanted to populate their bars all at once? TokenMod will do that, as written. What if you spawned 5 bandit mooks, and you wanted to populate their bars with slight variations on the values? Maybe not every bandit starts with 14 speed  exactly . Maybe there's some variation, there... anywhere from +/- 1d4. Maybe AC varies by +/-1, while HP can vary as much as +/-5.In that case, you might want to also have SelectManager. With SelectManager, ZeroFrame, and TokenMod,  you can run: !forselected(^) {^&global ([bar1Roll] [^[^@{SourceCharacterName|speed} + ([^[^1d4 * [^[^1d3 %  3 - 1^]^]^]^]) ^]^])([bar2Roll] [^[^@{SourceCharacterName|AC} + ([^[^1 * [^[^1d3 %  3 - 1^]^]^]^]) ^]^])([bar3Roll] [^[^@{SourceCharacterName|HP} + ([^[^1d5 * [^[^1d3 %  3 - 1^]^]^]^]) ^]^])}token-mod --set bar1|bar1Roll|bar1Roll bar2|bar2Roll|bar2Roll bar3|bar3Roll|bar3Roll And each will get an individual value for their speed, AC, and HP. Just replace  SourceCharacterName with the name of the actual character supporting the stat block, then select all the mooks and run the above. Here is a group of mooks that I used this on, and you can see they all got slightly different values... If you wanted, you could even start them at a small diminishment of their HP (or one of the other bars), if you wanted to throw in that wrinkle of authenticity... but I'm probably already deeper in the rabbit hole than you want to go.
Hiya Timmaugh So I tried this specific script as a bar button (obviously with the TokenMod API running): !token-mod --set bar1|@{selected|speed}|@{selected|speed} bar2|@{selected|AC}|@{selected|AC} bar3|@{selected|HP}|@{selected|HP} Unfortunately it only populated one of the bubbles.   It seems really rather complicated to get this working.  Any suggestions?  It seems as though it should be the easiest thing in the world to fix! Cheers!  :) Mike
1687526966
timmaugh
Forum Champion
API Scripter
Hmm... that command works for me. Also, if using a script is what seems to be complicating this, there is no other way to do it. Standard macros (Collection tab macros and Ability macros) are only capable of reading information, not writing it. To write information (like changing bar values, or changing a character attribute) you need a script. So, while you might get a dedicated script to do this one job (linking the 3 bubbles/bars), it will still be a script... and TokenMod is super versatile. For now, a couple things to check: Restart your sandbox. Sometimes it quietly crashes (no error), but a restart can give it a quick kick. Does your selected token actually have values in the attributes you want? Run this to quickly check: &{template:default}{{name=Attribute Check for @{selected|character_name}}} {{Speed=@{selected|speed} }} {{AC=@{selected|AC} }} {{HP=@{selected|HP} }}