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

Suggested Approach for using ChatSetAttr or other API/macro combo to record total roll from rollable tables

1554746254
John B
Pro
Sheet Author
So I have a game where I have a rollable table that represents each individual's demand and so each outcome is part of the demand for a category of stuff.  When I write the set command where the rollable table is directly in the request to the API it is recording it as an array of values rather than the sum of all the rolls.  This demand table is part of an economy downtime thing I've got playing between the game and actually need the total amount not all the individual rolls.   If I put the roll into an ability and request this ability through a roll query first it will sum it and then I can reuse the roll query again to get it into the attribute.  But this is an extra human interaction step to just make it so it uses the sum though and so wondering if there is some setting or method of writing the !setattr or !modattr to record the roll total? ?{Food Demand|Calculated,%{Blackrock|Food}|0} ?{Food Demand2|Calculated,%{Blackrock|Food2}|0} !setattr --name Blackrock --cons_food|[[?{Food Demand2}]]|[[?{Food Demand}]] The ability scores for Food is : [[@{Skilled }t[Skilled-Food]]] The ability score for Food2 is [[@{Labor }t[Labor-Food]]] And both tables look similar though the values are different. So any suggestions on how I can succeed at my goal with removing the roll queries part and still get a summation that would be great.
1554750007
GiGs
Pro
Sheet Author
API Scripter
I'm having trouble understanding what you're trying to do here - I've reread that first two paragraphs seveeral times and can't make sense of it. Which may be my failing. It sounds like you might need a custom script if you want to cut down the steps. Can you describe exactly what you're trying to with without reference to your existing macros or scripts? Describe the subsystem as if you are describing it to a player, or as it might be described in  game's rulebook, and if I can grasp it, i'll try to suggest the best way to achieve it.
1554752267
John B
Pro
Sheet Author
I'm doing some economic modeling off of D&D 5e rules.   They have consumption for food and shelter defined and so I'm using that to come up with what a settlement per day/week/month would consume.  So I'm trying to simulate that by having a range of gp value of food that the people of the settlement of Black rock would demand.  I need to record these into a character sheet for other portions of the simulation to work.  There are weekly economic turns for this settlement that the players are managing and taxing.   So using a rollable table I have an array based on consumptions that a squalid, poor, modest, comfortable, wealthy and aristocrat consume.  I have broken it up into two groups one considered labor which is the squalid and poor lifestyles and the other skilled which is modest and above.  So the number of dice being rolled is each of these demographics demand for the week. So in this week there are 474 residents that are considered labor and another 386 are considered skilled for determining consumption.  That then is the number of rolls per day on each of their respective tables where the sum is that demographics demand for food in gp.   This type of stuff is done often in the real world with spreadsheets to simulate a new product and what they know about demand and elasticity for the good or service.  I'd like to not have prompts to get to a sum but it seems as if I need that step for it to add it up instead of entering it as a comma delimited array which each entry is a roll from that table which is not useful for this. 
1554753198

Edited 1554753347
GiGs
Pro
Sheet Author
API Scripter
i think the reason you are getting arrays in your setattr command might be the syntax - I dont think the second | should be there in this: !setattr --name Blackrock --cons_food|[[?{Food Demand2}]]|[[?{Food Demand}]] It should maybe be something like !setattr --name Blackrock --cons_food|[[?{Food Demand2}]]+[[?{Food Demand}]] Maybe this will work? Replace all your code with: !setattr --name Blackrock --cons_food|[[@{Skilled }t[Skilled-Food]]]+[[@{Labor }t[Labor-Food]]] Should those spaces be in the attribute names? should  @{Skilled }  be   @{Skilled} ?
1554755185
John B
Pro
Sheet Author
No the existing code does not create an array but the suggestion you gave me does.  The existing code works but I now have to answer two questions that are just there so it adds it together rather than sums it like how an inline roll would normally work. So this is the outcome of the change you suggested: .5, .4, .5, .6, .5, .5, .5, .6, .5, .6, .5, .4, .5, .4, .5, .5, .4, .6, .4, .4, .5, .6, .5, .6, .5, .4, .4, .4, .6, .5, .4, .5, .5, .6, .6, .5, .6, .5, .6, .6, .5, .5, .4, .4, .4, .5, .4, .5, .6, .5, .5, .4, .4, .4, .4, .5, .6, .5, .6, .4, .4, .6, .5, .5, .6, .5, .6, .6, .6, .5, .5, .4, .6, .4, .4, .5, .5, .5, .4, .6, .6, .6, .4, .5, .5, .4, .6, .6, .5, .5, .4, .4, .4, .4, .4, .5, .6, .4, .6, .5, .6, .5, .5, .5, .5, .4, .5, .5, .6, .5, .5, .6, .4, .6, .5, .5, .5, .4, .5, .5, .5, .4, .6, .5, .5, .5, .5, .4, .6, .4, .6, .6, .4, .6, .4, .6, .5, .5, .6, .4, .4, .6, .5, .5, .6, .5, .5, .6, .4, .5, .4, .6, .6, .4, .5, .5, .6, .6, .6, .4, .4, .5, .4, .5, .5, .6, .5, .6, .5, .6, .4, .6, .4, .6, .5, .6, .4, .6, .5, .6, .4, .6, .6, .4, .4, .4, .4, .5, .4, .5, .5, .6, .5, .6, .6, .5, .6, .6, .5, .4, .6, .6, .6, .6, .6, .4, .6, .6, .4, .6, .6, .4, .4, .6, .6, .5, .4, .4, .4, .6, .5, .4, .6, .5, .6, .4, .5, .6, .5, .5, .6, .4, .5, .5, .6, .5, .4, .5, .4, .4, .6, .6, .5, .6, .4, .5, .6, .5, .6, .5, .4, .4, .4, .5, .5, .6, .5, .4, .4, .6, .4, .4, .6, .5, .6, .5, .4, .6, .4, .5, .6, .4, .4, .5, .5, .6, .6, .5, .6, .5, .6, .6, .5, .4, .4, .6, .5, .4, .5, .6, .5, .6, .5, .6, .5, .4, .5, .4, .5, .5, .4, .4, .6, .5, .6, .6, .6, .5, .5, .6, .5, .5, .6, .5, .4, .5, .6, .4, .5, .5, .4, .4, .4, .5, .5, .5, .4, .6, .4, .6, .4, .6, .6, .6, .6, .6, .6, .5, .6, .4, .6, .5, .5, .5, .4, .5, .4, .6, .5, .5, .4, .6, .6, .5, .4, .6, .4, .6, .6, .6, .6, .6, .5, .4, .6, .6, .6, .5, .6, .4, .6, .5, .5, .4, .6, .4, .4, .5, .6, .6, .4, .6, .4, .6, .5, .5+.08, .14, .12, .14, .12, .1, .1, .1, .06, .06, .12, .14, .1, .06, .06, .06, .12, .12, .12, .14, .1, .12, .06, .06, .14, .1, .14, .1, .12, .08, .12, .06, .14, .08, .14, .06, .06, .08, .12, .06, .1, .1, .12, .1, .1, .1, .1, .12, .1, .14, .08, .06, .08, .14, .08, .06, .1, .08, .08, .08, .12, .14, .08, .1, .14, .1, .12, .1, .12, .14, .08, .06, .06, .08, .1, .06, .12, .12, .12, .06, .1, .1, .12, .1, .14, .08, .12, .08, .14, .12, .06, .14, .06, .08, .06, .06, .1, .14, .08, .14, .12, .14, .06, .08, .08, .08, .14, .06, .08, .1, .06, .06, .1, .14, .1, .14, .12, .06, .06, .14, .06, .12, .06, .06, .06, .14, .12, .14, .12, .14, .1, .1, .06, .08, .06, .12, .12, .14, .1, .14, .12, .06, .1, .14, .12, .06, .14, .12, .08, .14, .08, .08, .1, .12, .06, .1, .1, .06, .1, .1, .1, .06, .08, .14, .06, .06, .06, .1, .1, .1, .1, .14, .14, .06, .06, .12, .1, .06, .12, .06, .14, .12, .14, .08, .14, .14, .12, .06, .14, .14, .14, .14, .1, .06, .14, .1, .1, .14, .08, .1, .1, .12, .08, .08, .06, .06, .12, .08, .06, .14, .06, .1, .1, .1, .14, .12, .06, .1, .14, .1, .12, .08, .06, .1, .12, .12, .06, .1, .06, .1, .06, .08, .06, .14, .1, .08, .08, .1, .06, .08, .1, .06, .06, .06, .06, .14, .08, .14, .14, .1, .1, .14, .14, .1, .12, .1, .12, .12, .1, .06, .06, .08, .06, .06, .12, .1, .08, .14, .06, .06, .14, .06, .06, .1, .08, .08, .1, .12, .12, .06, .1, .1, .12, .08, .14, .08, .1, .06, .14, .08, .08, .1, .06, .08, .08, .12, .12, .08, .12, .06, .12, .14, .1, .1, .08, .14, .14, .14, .06, .1, .06, .06, .08, .1, .12, .08, .12, .14, .12, .06, .12, .06, .1, .06, .12, .1, .1, .12, .08, .08, .12, .08, .08, .06, .1, .1, .08, .08, .14, .08, .1, .08, .14, .08, .06, .1, .14, .12, .1, .06, .08, .12, .12, .08, .12, .1, .14, .14, .12, .1, .06, .08, .06, .12, .1, .12, .14, .1, .06, .06, .14, .08, .12, .08, .14, .12, .12, .12, .12, .08, .12, .12, .1, .12, .12, .14, .08, .1, .1, .14, .06, .14, .1, .1, .12, .14, .12, .08, .08, .06, .06, .14, .12, .1, .12, .06, .06, .06, .1, .06, .12, .08, .1, .06, .1, .08, .1, .1, .1, .1, .12, .1, .06, .1, .14, .06, .08, .08, .12, .06, .14, .14, .12, .14, .14, .14, .12, .14, .12, .06, .08, .06, .14, .14, .06, .08, .14, .08, .12, .1, .1, .12, .08, .06, .06, .1, .12, .1, .12, .1, .1, .1, .14, .14, .14, .14, .06, .12, .06, .12, .14, .14, .14, .06
1554757574
GiGs
Pro
Sheet Author
API Scripter
How about this (wrapping the roll in anotehr set of inline brackets) !setattr --name Blackrock --cons_food|[[ [[@{Skilled }t[Skilled-Food]]]+[[@{Labor }t[Labor-Food]]] ]] (The spaces there are just for readability)
1554757732
John B
Pro
Sheet Author
Oh I had thought I had tried that but evidently I didn't as that worked.  Thanks for looking at this and the suggestions.
1554757845
GiGs
Pro
Sheet Author
API Scripter
You're welcome :) Getting the syntax right is often a bit of trial and error!