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 not firing for all triggers

Hi all, I have a sheet worker that I want to run when an attribute is updated and when the sheet is opened, but it's only running when the attribute is updated. I've also tried setting it up to run when a "refresh" button is clicked, and that's not working either. The purpose of the worker is to take blocks of text describing the effects of powers, and modify them for alternate modes: one mode removes the brackets around inline rolls so that it doesn't roll anything; the other three modify the inline rolls so that it rolls multiple times and takes the best/worst/middle result, respectively. As mentioned, the script works as desired, it just doesn't trigger all of the times that I want it to. Worker Code:     const groups = ['basic', 'lesser', 'greater', 'feature', 'item', 'other'];     groups.forEach(function (group) { const texts = ['attack_hit_', 'attack_crit_', 'attack_miss_', 'attack_effect_', 'attack_maintain_', 'attack_special_']; texts.forEach(function (text) { on("change:repeating_" + group + ":" + text + group + " clicked:refresh sheet:opened", function() { usText = "repeating_" + group + "_" + text + group getAttrs([usText], function (values) { var fStr = values[usText] + " "; var dfStr = values[usText]; var fdfStr = values[usText]; let uniqueRolls = values[usText].match(/(?<=\[\[).*?(?=\]\])/g).filter(function (value, index, self) { return self.indexOf(value) === index; }); uniqueRolls.forEach(function(roll, index) { let rollMatch = "[[" + roll + "]]"; let fRoll = "[[{" + roll + "," + roll + "}d1]]"; let dfRoll = "[[{" + roll + "," + roll + "}dh1]]"; let fdfRoll = "[[{" + roll + "," + roll + "," + roll + "}kl2dl1]]"; fStr = fStr.replace(rollMatch, fRoll); dfStr = dfStr.replace(rollMatch, dfRoll); fdfStr = fdfStr.replace(rollMatch, fdfRoll); }); setAttrs({ [usText + '_noroll']: values[usText].split("[[").join("").split("]]").join("") + " ", [usText + '_f']: fStr + " ", [usText + '_df']: dfStr + " ", [usText + '_fdf']: fdfStr + " " }); }); }); }); }); Button Code: <button type="action" name="act_refresh"></button>
1595802872

Edited 1595802976
Figured it out; it's because the text blocks are in repeated sections. If I wanted to run a sheetworker on every entry in a repeated section upon opening, how would I do that?
1595847872
Finderski
Plus
Sheet Author
Compendium Curator
The way I would try it would be on opened you'd have to manually get the section IDs and then cycle through the repeating section with those, checking what you need to check. I don't have time to give an coded example, but the steps would be something like: On sheet opened => getSectionIDs => get fully qualified fields and put them in an array => getAttrs => do what you need => settAttrs