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

[Help] setAttrs

1550730366
Sad
Sheet Author
API Scripter
Hi, i have a question when i create a function. First i have two input box named skill_custom_bonus_A & B. Then the function would change the   skill_custom_bonus_B value  when skill_custom_ability  changed. Now the problem is the input box won't  display the new number. But it will work fine when i call @{skill_custom_bonus_b} in button. <input type="number" name="attr_skill_custom_bonus_A" class="nospin number underlined greybg" value="0" disabled /> <input type="number" name="attr_skill_custom_bonus_B" class="nospin number underlined greybg" value="0" disabled /> on("change:skill_custom_ability change:skill_custom_skill_custom_name sheet:opened", function () { getAttrs(["skill_custom_skill_custom_name", "skill_custom_ability"], function (value) { switch (value.skill_custom_ability) { case "@{strength_sum}": setAttrs({ skill_custom_bonus_B: "[[@{strength_bonus_sum}]]" }); break; case "@{dexterity_sum}": setAttrs({ skill_custom_bonus_B: "[[@{dexterity_bonus_sum}]]" }); break; case "@{stamina_sum}": setAttrs({ skill_custom_bonus_B: "[[@{stamina_bonus_sum}]]" }); break; case "@{intelligence_sum}": setAttrs({ skill_custom_bonus_B: "[[@{intelligence_bonus_sum}]]" }); break; case "@{Wits_sum}": setAttrs({ skill_custom_bonus_B: "[[@{Wits_bonus_sum}]]" }); break; case "@{resolve_sum}": setAttrs({ skill_custom_bonus_B: "[[@{resolve_bonus_sum}]]" }); break; case "@{presence_sum}": setAttrs({ skill_custom_bonus_B: "[[@{presence_bonus_sum}]]" }); break; case "@{manipulation_sum}": setAttrs({ skill_custom_bonus_B: "[[@{manipulation_bonus_sum}]]" }); break; case "@{composure_sum}": setAttrs({ skill_custom_bonus_B: "[[@{composure_bonus_sum}]]" }); break; default: setAttrs({ skill_custom_bonus_B: 0 }); }
1550731204

Edited 1550731375
GiGs
Pro
Sheet Author
API Scripter
You need to remove disabled from the inputs. Sheet workers can't affect disabled inputs. If you don't want players to modify the input, replace disabled with readonly . e.g. <input type="number" name="attr_skill_custom_bonus_A" class="nospin number underlined greybg" value="0" readonly /> Some questions that occur to me as I look at your sheetworker: In your sheet worker change line, is this name correct?  change:skill_custom_skill_custom_name  It looks weird, so I'm just checking. Also, it looks like  skill_custom_skill_custom_name isn't actually used anywhere in the sheet worker, so you can probably safely remove it from the change and getAttrs lines. Its kind of weird that you are using a sheet worker to create autocalc fields. It will work, but an alternative approach is to grab the appropriate stats and insert them instead. You have  skill_custom_ability having values like @{strength_sum} . Are they used for anything other than this sheet worker? If so, you could simplify that by just using "strength" instead of "@{strength_sum}".
1550732831
Sad
Sheet Author
API Scripter
Thank you GiGs I found the problem!