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

Pre-filled Repeating Section

Is there any way to set values for repeating sections to be set when a new character sheet is created? For example, in Fellowship, the Elf has a move called "Elder Arts" that grants them a set of spells they can cast, although each spell can be cast once until it's recovered by eating or recovering (which is why I want to track them on the character sheet). However, the Elf starts with 4 spells... but one character creation option lets them start with a 5th, and there's a 6th in the Custom Moves that can be taken at creation or during advancement. Meanwhile, non-elves can "share" the move, but they have to pick one of the spells and can only cast that one (unless it gets shared multiple times). So, it would be useful to start with a list of 4 items, but allow players to add or delete them, including the original 4, as needed. Is this possible?
1519018473
Finderski
Plus
Sheet Author
Compendium Curator
Should be, via sheetworkers...
1519020617

Edited 1519020638
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Can confirm, this is possible via sheetworkers, something like this: on('change:class_1_name',(event)=>{ var setObj = {}; if(event.newValue.toLowerCase()==='elf'){ // create the repeating items here as needed for the spells in question. Use generateRowID() // to create the row IDs } setAttrs(setObj,{silent:true}); });
Thanks to both of you, in previous readings of the Sheet Worker Scripts docs I missed that they could generate repeating sections. I got it working with this code (I'll probably add a "hasElderArts" attribute later to trigger this for other characters, but there are a lot of optional sections like this to add toggles for): on("change:class", function(eventInfo) {          if(eventInfo.newValue == "Elf"){         getSectionIDs("elder-arts", function(idarray) {                        if (idarray.length == 0) {             var rowid1 = generateRowID();             var rowid2 = generateRowID();             var rowid3 = generateRowID();             var rowid4 = generateRowID();             var newattrs = {};                          newattrs["repeating_elder-arts_" + rowid1 + "_nameElderArt"] = getTranslationByKey("camouflage");             newattrs["repeating_elder-arts_" + rowid2 + "_nameElderArt"] = getTranslationByKey("keen-senses");             newattrs["repeating_elder-arts_" + rowid3 + "_nameElderArt"] = getTranslationByKey("sense-magic");             newattrs["repeating_elder-arts_" + rowid4 + "_nameElderArt"] = getTranslationByKey("whisper");             setAttrs(newattrs);           }         });     } });