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 help] include some repeating rows by default?

1551338173
vÍnce
Pro
Sheet Author
I'm working on a sheet that just looks like Swiss cheese(no offense if you are Swiss or cheese...) until you start adding some repeating items.  Is it possible to include an "X" number of blank repeating rows by default?  If so, how?  Sheetworkers?  TIA
1551342302

Edited 1551342352
GiGs
Pro
Sheet Author
API Scripter
The way I've done this in the past is to include X number of normal inputs, not a repeating section, and only use the repeating section for the extra rows. having both the normal elements and repeating fieldset elements styles the same so users can't tell they are different. It works well, since the + and Edit buttons for the repeating fieldset appear directly below the non-repeating elements, so they really do look like they are part of the same unit. That said, if you really need to do it in a repeating fieldset, you could do it with a sheet worker, and the same kind of sheet:opened  event you use with version checking. Create a hidden readonly input, set its default value to 0 Have an event on("sheet:opened"), which checks that value. if it is 0, it runs, doing these steps:     Create the number of new repeating sections (using setAttrs)     change the hidden input value to 1 (or anything else), so it never runs again. You'd need to use generateRowID  to create an id for each new row, and would then use setAttrs to create the row (by just setting the value of one attribute within the row). This means that the first time - and only that time - the sheet is opened, the needed rows will be created.
1551344846
vÍnce
Pro
Sheet Author
I may add the additional "hard-coded" rows (I have a feeling that most users will never have a need beyond that) just because I know I can easily handle that, but your sheetworker method sounds appealing...  Thanks GiGs
1551351765
GiGs
Pro
Sheet Author
API Scripter
If you want to try it, here's a test sheet worker I did. I created a new fieldset called repeating_test, added an input called value, and used this sheet worker: on("sheet:opened", function() {  getAttrs(['check_opened'], function(v) { const opened = v.check_opened*1||0; if(opened !== 0) return; const settings = {}; //create an object to store the new rows let numRows = 3; // set how many rows you want to create         while (numRows--) { // loop a number of times equal to the rows.                 const newrowid = generateRowID();                          settings["repeating_test_" + newrowid + "_value"] = numRows;         }         settings['check_opened'] = 1; // remember to set the first run variable to not-zero setAttrs(settings); }); }); I also created a hidden check_opened attribute, with a value of zero. It worked! One thing does occur to me: if you are creating a set of default entries in your table, and want specific values in them, you have to be careful that players don't delete them. So rather than testing for a check_opened variable, you might instead have a script that always runs on sheet:opened,  and checks that each of the rows you want are in the repeating set, and recreat them if not. That's a little trickier, but not too hard. Of course, just having fixed inputs outside the repeating fieldset completely avoids the need for that, so is probably the superior way anyway.