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

[Request] Targeting all tokens to sum up all Mana values

Hi my goal is to simulate maintenance cost, having some tokens have a positive value (city tokens produce) and the other tokens a negative value (unit tokens cost) With a macro you can semi do this, but need to select a specific number of tokens to add up their mana bar values: &{template:default} {{name=Resources (5) total}} {{Red Total=[[@{target|target1|bar3} + @{target|target2|bar3} + @{target|target3|bar3} + @{target|target4|bar3} + @{target|target5|bar3} ]]}} {{Green Total=[[@{target|target1|bar1} + @{target|target2|bar1} + @{target|target3|bar1} + @{target|target4|bar1} + @{target|target5|bar1}]]}} {{Blue Total=[[@{target|target1|bar2} + @{target|target2|bar2} + @{target|target3|bar2} + @{target|target4|bar2} + @{target|target5|bar2} ]]}} Now, I'm going to try to do this myself, but if in the meanwhile someone swoops in and kinda does it, that would be great as well XD Cheers!
1444475101
The Aaron
Pro
API Scripter
So, you're just looking for code to sum each of the bars of the selected tokens?
That would be a good start, but for my game I would like to sum the bars of *all* tokens :)
1444563132
The Aaron
Pro
API Scripter
Across all pages or just the current "page"?
Hm, good one To sum each of the bars of all tokens in the current page
1444747774
The Aaron
Pro
API Scripter
For the current page, is it sufficient to use the current player page, or would you as GM want to be able to specify a different page?  Would players ever be split across multiple pages and running it individually?
1444830509
The Aaron
Pro
API Scripter
Ok, I threw together a simple version of this. &nbsp;There is one command: !total-mana -- Calculates the sum of each bar of the tokens for the current player page and displays it in the chat: Tokens considered are those that meet the following criteria: On the correct page Are graphics Are not drawings Are on the Objects layer Selecting a token on a page will cause tokens on that page to be calculated instead of the ones on the current player page. We can use this as a jumping off point for other changes if this isn't sufficient to your needs. &nbsp;=D Git:&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/To" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/To</a>...
1444866175

Edited 1444866237
WurmD
KS Backer
Aaron, here I was, saying I was going to program, but playing instead, and you come and do it all for me! It does exactly what I need! ^_^ I've already fiddled with the display to make it read "Income: " "Maintenance: " "Upgrades: " "Total: " where total is the summed value from the three ^_^ (bars) and with this, a game that was previously played through spreadsheets, and lots of copy pasting between players and GM, now can be totaly played in Roll20 ^_^ What a great success If you're curious, it's this game:&nbsp; <a href="http://forums.erfworld.com/viewtopic.php?f=23&t=7699&start=100" rel="nofollow">http://forums.erfworld.com/viewtopic.php?f=23&t=7699&start=100</a> :D&nbsp;
sendChat('','&lt;div style="border:1px solid #999; border-radius: 1em; padding: .5em; background-color: #ccc;"&gt;'+ '&lt;div style="text-align: center; font-size: 1.3em; font-weight:bold; border-bottom: 2px solid #999; margin:.5em;"&gt;'+ 'Mana Totals'+ '&lt;/div&gt;'+ '&lt;div&gt;'+ '&lt;div style="float:left;font-weight:bold;margin-right: 1em;"&gt;Bar3(red) Income:&lt;/div&gt;'+ totals.bar3 + '&lt;/div&gt;'+ '&lt;div&gt;'+ '&lt;div style="float:left;font-weight:bold;margin-right: 1em;"&gt;Bar1(green) Maintenance:&lt;/div&gt;'+ totals.bar1 + '&lt;/div&gt;'+ '&lt;div&gt;'+ '&lt;div style="float:left;font-weight:bold;margin-right: 1em;"&gt;Bar2(blue) Upgrades:&lt;/div&gt;'+ totals.bar2 + '&lt;/div&gt;'+ '&lt;div&gt;'+ '&lt;div style="float:left;font-weight:bold;margin-right: 1em;"&gt;Total:&lt;/div&gt;'+ (totals.bar3+totals.bar1+totals.bar2) + '&lt;/div&gt;'+ '&lt;/div&gt;' );
1444874716
The Aaron
Pro
API Scripter
Very Cool! &nbsp;Let me know if you need anything else. =D
Here is where I am atm: <a href="https://gist.github.com/WurmD/21b4470c9e0b5a69a2f8" rel="nofollow">https://gist.github.com/WurmD/21b4470c9e0b5a69a2f8</a>... I was wondering if I should make a pull request on your github, but I'm thinking not, since this has become very game specific !total-money : Sums up the values in bar3 (red) of the token with name that starts with "Treasury" and displays that as "Treasury before:" Sums up the values in bar3 (red) of the tokens with name "City", counts the number of such tokens; Sums up the values in bar3 (red) of the tokens with name "Farm" or "Mine"; Displays as "Income:" sum of city income *0.95^(N-3) where N is number of cities, plus the income of Farms and Mines&nbsp; Sums up the values in bar1 (green), and displays that as "Maintenance:" Sums up the values in bar2 (blue), and displays that as "Upgrades:" Sums all that up to give "Treasury after:" &nbsp; !names2GMnotes: Copies all the names of tokens into GMnotes (to back them up if you had already written some in name) !maint2names For tokens without maintenance value, does nothing For tokens without names, sets the name to their bar1 value (their maintenance value) For tokens with names stored in gmnotes, set the name to the name in gmnotes and concatenates to that their maintenance value To help spotting tokens without maintenance value set !names-off Turns all nameplates off.
1446030875
The Aaron
Pro
API Scripter
That's a load of work, nice job! &nbsp;Don't worry about sending me a pull request, you've made that script your own. :). I'd suggest changing the name of the module to something more appropriate and stripping out the links to mine as well as the author tag for me.&nbsp;