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

[stupid question] is there a way to make an attribute hold multiple values?

1611668408
CKenny
Sheet Author
Hello everyone, My question is:  it is possible to make an attribute behave like an array? I.e. something like this : <select name='attr_acrobatics'>     <option value='@{strTotal}' value2='@{strBonus}' >STR</option>     <option value='@{agiTotal}' value2='@{agiBonus}' selected='selected'>AGI</option> </select> <button type='roll' name='acrobatics_roll' value='{{roll=[[1+floor(abs([[@{acrobatics[0]}]]+0.5-[[1d100]])/10)+]]@{acrobatics[1]}}}'> I know i could set up a sheet worker but I was wondering if it was possible without one
1611671089
GiGs
Pro
Sheet Author
API Scripter
No it's not possible to do this, you'll need to use a sheet worker. create your select like so, and add a hidden input to hold a value you'll calculate in your sheet worker. Then call that attribute in your button. <select name='attr_acrobatics'>     <option value='str' >STR</option>     <option value='agi' selected='selected'>AGI</option> </select> <input type="hidden" name="attr_acrobatics_roll" value=''> <button type='roll' name='roll_acrobatics' value='@{acrobatics_roll}'> then in your sheet worker get the various attributes you might need, and build the string for the button there, like so: on ( 'change:acrobatics' , ()  =>  {      getAttrs ([ 'acrobatics' ],  values   =>  {          const   selected  =  values [ 'acrobatics' ];          const   roll  =  `{{roll=[[1+floor(abs(@{ ${ selected } Total}+0.5-[[1d100]])/10)]]+@{ ${ selected } Bonus} }}`;          setAttrs ({              acrobatics_roll :   roll         });     }); }); This grabs the value in the select, which will be something like 'agi' or 'str', which you can then add to 'Bonus' and 'Total' to construct your roll.  This line is complex:         const roll = `{{roll=[[1+floor(abs(@{${selected}Total}+0.5-[[1d100]])/10)]]+@{${selected}Bonus} }}`; and can be rewritten like this if its more understandable:         const roll = '{{roll=[[1+floor(abs(@{' + selected + 'Total}+0.5-[[1d100]])/10)]]+@{' + selected + '}Bonus} }}';
1611674172
CKenny
Sheet Author
Thanks GIGs, This is the 2nd time you come to my help. As I stated earlier I knew I would need to use a sheet worker, but as I was starting to write it, I was wondering if it was really needed