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

Percentage of loot

Could use a hand with this, not really something I've tried with R20 macros before. The aim is to take 70% of the party gold, divide the rest by the number of party members. Process flow: 1) Input in a number field the value of the total party gold earned. 2) Find 70% of that and value that number. the second part is to take that 70% and remove it from the total to display the remaining amount. 3) Ask for input on the number of party members and divide that amount by them. I some of the the parts but stuck with: Total Gold was ?{Total Gold|0}  70% for the city is ?{City Gold| [[ ((?{Total Gold})/100)*70 ]] } Total Party members ?{Total Party Members|0} Party split is [[ ?{City Gold|0} / ?{Total Party Members|0} ]] Not sure how to make that 70% output a variable so it can be called in the next stage.
Found a workaround with a different flow: /em Session Gold Calculation     Total Gold was ?{Total Gold|0}  70% for the city is [[ ((?{Total Gold})/100)*70 ]] 30% for the party is [[ ((?{Total Gold})/100)*30 ]] Gold per person [[ [[ ((?{Total Gold})/100)*30 ]] / ?{Total Party Members|0} ]]
You cannot assign a value to a variable in macro syntax. You can reuse the value of a query within a macro, so I came up with something like this for you.  Total Gold was **?{Total Gold|0}**; 70% for the city is [[ ((?{Total Gold})/100)*70 ]]; Total Party members is **?{Total Party Members|0}**; Party split is [[((?{Total Gold})/100)*70 / ?{Total Party Members|0} ]]
1593276631
GiGs
Pro
Sheet Author
API Scripter
Tim's approach is excellent. Though I think the party split should be x30 not x70. i just wanted to add you could put it in a rolltemplate to get easier-to-scan output: &{template:default} {{name=Gold Award}} {{Total Gold=[[ ?{Total Gold|0}]]}} {{City Portion=[[ ?{Total Gold})/100)*70]])) {{Party Size=[[ ?{Total Party Members|0}]]}} {{Member Split=[[ [[( ?{Total Gold}/100)*30]] /  ?{Total Party Members}]]}} I put inline roll brackets around total gold and party size, even though it's not necessary, so that all the numbers would be in the same format.
Thanks both, I actually adapted it further after writing that too in a similar line of thought: !?{Total Gold|0}  &{template:traits} {{name=Session Gold}} {{source: }} {{description=Total Gold was [[ ?{Total Gold|0} * 1 ]]  70% for the city is [[ ((?{Total Gold})/100)*70 ]] 30% for the party is [[ ((?{Total Gold})/100)*30 ]] Gold per person [[ [[ ((?{Total Gold})/100)*30 ]] / ?{Total Party Members|0} ]]}}