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

Specific Attribute in repeating section not recognized

1544728131
Quinn
Pro
Sheet Author
Working on a character sheet, I have a button inside a repeating section - it's a list of techniques, and clicking the button will roll the technique. However, one specific value in it is refusing to work, and I'm out of ideas trying to figure out why. I have a worker listening to changes to a technique that updates various derived values for it. One of the settable values on the sheet is which attribute it uses, so when the user changes that value (repeating_techs_X_tech_stat), I have the worker set the display name accordingly (repeating_techs_X_tech_stat_name). The basic code for that looks like this (simplified): techFieldNames.push('repeating_techs_' + techId + '_tech_stat'); techFieldNames.push('repeating_techs_' + techId + '_tech_stat_name'); getAttrs(techFieldNames, function(techValues) {     let techStat = techValues['repeating_techs_' + techId + '_tech_stat'];     let techStatName = techValues['repeating_techs_' + techId + '_tech_stat_name'];     log(techName);     log(techStatName);     ...(lots of stuff happens)...     techStatName = attributes[techStat].name;     log(techStatName);          let attrs = {};     attrs['repeating_techs_' + techId + '_tech_stat_name'] = techStatName;     ...(more attributes added)...     setAttrs(attrs, { silent: true }); } If I set the technique's attribute value to 'agi', then this code runs and logs 'agi', then 'Agility', then 'Agility', indicating that it's setting the value of tech_stat_name correctly. I've added a span to the repeating section's HTML that displays the value of tech_stat_name, and it shows 'Agility'. However, when I click the following ultra-basic macro button: <button type='roll' value='Name: @{tech_name} Stat: @{tech_stat_name}'> Use Technique</button> I get this: If I change @{tech_stat_name} to any other value the technique has, it works. I have no idea what's different about this one. Am I missing something straightforward and obvious here?
Can you show the code where the tech_stat_name attribute is created?
1544729170

Edited 1544729976
Quinn
Pro
Sheet Author
I believe it's being created by the "setAttrs(attrs, { silent: true });" call above - the _tech_stat_name attribute is added to attrs, and then setAttrs being called should be creating that attribute, right? e: I tried with another one of the generated derived attributes (tech_cost) and ran into the same trouble. I might be missing some step of establishing formally that an attribute exists.
1544729987
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
What we need though is the html of the repeating section. I think what is going on here is that you are only using an attribute backed span for the tech_stat_name attribute. Attribute backed spans in repeating sections are frequently hinky, and should pretty much always be backed up by an input version of the attribute (use type='hidden' if you don't actually need the input version displayed anywere): <input type='hidden' name='attr_tech_stat_name' value=''>
1544730440
Quinn
Pro
Sheet Author
Here's a pastebin of the fieldset , again simplified. I've added in hidden input for thet derived stats, and it did resolve the error message, but now it just says "Name: Sword Attack Stat: " with no stat listed.
No stat is listed because no value is set for the attribute. How do you expect this value to be set and by whom? If it is set within the API, are you actually changing the value within the sheetworker? As it is currently you are hiding this attribute from the player and default it's value to an empty string. If this attribute is meant to be set from within the character sheet rather than through the API. You need to change the type of the Attribute from hidden to text  and then set the value from within the character sheet before click the roll button.
1544740099
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Kyle,see my post right above profs last one for why he's doing this.
1544765963
Quinn
Pro
Sheet Author
I feel like I understand how attributes work much less than I thought. tech_stat_name is an attribute to be set by the worker, when the user changes the tech_stat via the select. The sheet worker listens for a change to tech_stat, then sets tech_stat_name accordingly via setAttrs. How is that not assigning a value to the attribute?