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

Display a global attribute in a repeating section without disabled input

Hi, i described my problem in the title, Actually I'm working on removing disabled input in my sheet to make it go faster(discussed on another topic 1-2 week ago), and i have "lines" corresponding to preconfigured rolls, on them i had some cells displaying "wound-penalty" or "roll-penalty"(which only apply to rolls and not static values, anyways x) ) The thing is, i used "disabled" input cell to display the global attribute inside the repeating line, and i cannot find a way to display the global attribute with an input readonly or a span, so i have to "push" the new data to each repeating sections and i'd prefer not to x) I searched on the internet and on the wiki but ... i didn't find a way, if you have this information i'd be really grateful ! Have a good day
1714112361

Edited 1714112630
GiGs
Pro
Sheet Author
API Scripter
I'm not following your situation. Can you describe what you are trying, in more detail? To be cear: displaying a global attribute in a repeating section should not be a problem. Are you trying to display the value of a fixed attribute created somewhere else on the sheet? i cannot find a way to display the global attribute with an input readonly or a span, so i have to "push" the new data to each repeating sections and i'd prefer not to x) I'm not following exactly what you are trying to do, but if you want to display an attribute's value on every row of a repeating section, this is exactly what you have to do. Note: when you have created an attribute in one place, and want to display a separate attribute with the same value in another (whether in repeating section or not), you are creating a copy of that original attribute. You always have to push its value to the new attribute. If you are creating a calculation, and don't want to recalculate it for every row, then I have good news for you: you don't have to do that. You can calculate it once, and paste it into every row. But we need to know more details (like actual code or at least relevant attribute names and the calculation to be performed) to know what advice to give.
GiGs said: To be cear: displaying a global attribute in a repeating section should not be a problem. Are you trying to display the value of a fixed attribute created somewhere else on the sheet? i cannot find a way to display the global attribute with an input readonly or a span, so i have to "push" the new data to each repeating sections and i'd prefer not to x) I'm not following exactly what you are trying to do, but if you want to display an attribute's value on every row of a repeating section, this is exactly what you have to do. Ok, so in have a global attribute named "wound-penalty" which is set through code/calculation in js, a "repeating_roll" section which contains his own attributes in html and accessed/modified through js. As i have understood by reading and experimenting since when i started my sheet, if you have an input named "attr_wound-penalty" inside the previously mentioned repeating section, it will in fact access to an attribute named "repeating_roll_IDOFTHEROW_wound-penalty", when in fact i'm trying to display the global one (and/but not give "edit" right through the input inside the repeating section). So, actually without disabled fields, the only way i found is by using readonly inputs or spans, which needs that the  "repeating_roll_IDOFTHEROW_globalattr " is set to the same value as my "wound-penalty" is that a bit clearer ? else i'll write some code to illustrate my problem because i'm not sure i have a short enough example in my sheet
1714124212
GiGs
Pro
Sheet Author
API Scripter
Groch said: So, actually without disabled fields, the only way i found is by using readonly inputs or spans, which needs that the  "repeating_roll_IDOFTHEROW_globalattr " is set to the same value as my "wound-penalty" is that a bit clearer ? else i'll write some code to illustrate my problem because i'm not sure i have a short enough example in my sheet I'd like to know how the global wound_penalty is calculated, and if it affects any other attributes in the repeating section, because that changes things, but I can show one way to apply it. Note that you have " repeating_roll_IDOFTHEROW_globalattr " but it's actually " repeating_roll_IDOFTHEROW_anything-valid" - the name used in the repeating section doesn't have to be linked to the name of the global attribute. Note also: the following only applies if you want to display the value. If you want to use the value in a roll, you can just use @{wound-penalty} - as long as there is no conflicting similar name in the repeating section, that value will be used directly in any macros. So, assuming you want to display it - this is going to look complicated, but there are several parts put together that are each fairly simple. on ( 'change:wound-penalty' , () => {     getSectionIDs ( 'repeating_roll' , ids => {         const fields = [];         ids . forEach ( id => {             fields . push ( `repeating_roll_ ${ id } _wound-penalty` );         });         getAttrs ([ 'wound-penalty' ], values => {             const wound = + values [ 'wound-penalty' ] || 0 ;             const output = {};             fields . forEach ( field => {                 output [ field ] = wound ;             });             setAttrs ( output );         });     }); }); First, you need to monitor the global attribute. The lines under getSectionIDs create an array here called fields. This array contains one attribute for each row in the repeating section. The id variaable is the  IDOFTHEROW part. The getSectionIDs function is how you get those. Then in getAttrs, you get the current value of the wound, and loop through fields, saving the value of wound to each attribute stored in the fields array. Then you use setAttrs to ave those values. This could be condensed to make the worker less intimidating-looking, but it would be much harder to understand. If you have any questions on how to understand this, or how to do what you actually intend to do, ask away.
1714143854

Edited 1714172905
Don't worry about understanding code, i'm a developper IRL so its no problem Yeah you answered what i thought, if i want to display it, i have to update each row with an attribute. And sadly yeah it's only to display it, i already know that if you only need to include the value in the roll sent to chat then you can just do it no problem. But to answer some of your questions : for the wound penalty i have to retrieve each health from a repeating section, see if its "checked", and if it is then, the corresponding penalty is -1 -2 or -4, they are sorted ... well, its a WoD health system. Then this value is only sent to the dice roller when the player click the button to send the roll, but on some of my dice roller UI, i'd prefer to include each penalties and calculate the total of dices and success of a roll before sending it, and displaying it to my players (as a visual feedback of what is going to happen), There is my issue, if i want to show in this line the wound penalty, i have to have the wound-penalty replicated from the global attr to one of repeating section, especially if it's only to "display" and not "use" it (i retrieve the global attribute in JS when doing my line calculation for the total dices to be rolled, so yeah it affect one other attribute in the repeating section), and as i am in a process of removing "unnecessary" things it seems to fit in that category xD Thanks for your time :)
1714244792

Edited 1714244809
GiGs
Pro
Sheet Author
API Scripter
I would have an attribute to show the full wound penalty as a single number. Do you have a sheet worker connected to the wpiunds repeating section to calculate your wounds? I have to say, it's difficult to answer your questio because I don't know the code for the relevant parts of the sheet. I have given you what I think you need. What exactly do you need?