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

[Sheet Worker] Select the highest number from this list

I have 8 sets of radio buttons.  Each set is named "healthbox_(number).  I want to make a script worker that selects the highest of those numbers and displays it in a numberbox named "injury". How do I do that? Bonus Question: I would love to round down the number selected.  How does that happen?
1485476271

Edited 1485476290
Kryx
Pro
Sheet Author
API Scripter
Highest Value & Round: getAttrs(['healthbox_1', 'healthbox_2'], (v) => { Math.floor(Math.max.apply(null, Object.values(v))); });
No understanding.  Would the total code look like: on("change:healthbox_1 change:healthbox_2 change:healthbox_3 change:healthbox_4 change:healthbox_5 change:healthbox_6 change:healthbox_7 change:healthbox_8 sheet:opened", function() {     getAttrs(['healthbox_1', 'healthbox_2', 'healthbox_3', 'healthbox_4', 'healthbox_5', 'healthbox_6', 'healthbox_7', 'healthbox_8'], function(values) {         setAttrs({              injury: Math.floor(Math.max.apply(null, Object.values(healthbox_1, healthbox_2, healthbox_3, healthbox_4, healthbox_5, healthbox_6, healthbox_7, healthbox_8))); });
1485477119
Kryx
Pro
Sheet Author
API Scripter
Correct except the 4th line. Replace all the fields with "Object.Values(values)"
That works beautifully.  Thank you very much!