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

auto create repeating row on character creation.

I have a repeating section which I am using as a character journal. Is there a way to create a row 0 automatically when the character is first created?
1614972968

Edited 1614977035
GiGs
Pro
Sheet Author
API Scripter
It is possible, but it's easier to just add a row outside the repeating section, styled the same as a repeating section. If you do want to use a repeating section, something like this should work on ( 'sheet:opened' , ()  =>  {      getSectionIDs ( 'repeating_pages' ,  idarray   =>  {          if ( idarray . length  >  0 ) {              return ;         }  else  {              const   rowid  =  generateRowID ();              setAttrs ({                  [ `repeating_pages_ ${ rowid } _page` ]:   'Journal'             });         }     }); }); you need to rename the ALL CAPS words with the appropriate value from your sheet: SECTIONNAME: the repeating section name ATTRIBUTE: an attribute within the repeating section. It's best to assign some placeholder text to an attribute in the section. so you could change 'write something here' to whatever you need it to be, just so that something  is created.
I have each row styled to look like pages. I also have a hidden input in each row that is set to 0 for everything except the current row. The CSS is set to hide any row that has a zero, so it only shows the current row, which can be changed with buttons that turn the pages, and add a new page if you turn past the highest page. I want to hide the Add/Modify buttons, but I need there to be a page zero, or else there is no way to add new pages. I thought  sheet:opened  triggered every time the sheet is opened.
1614975978
GiGs
Pro
Sheet Author
API Scripter
sheet:opened  does trigger when the sheet is opened, butt his part: if(idarray) {             return; checks to see if any rows already exist, and if they do, ends the sheet worker. So the creating a row only happens if the repeating section is empty. Note that there is no event for when a character is created, sheet:opened  is the best we have for that.  Since the sheet must be opened to be used, its the only event we have that is guaranteed to happen.
It doesn't work. What i have is as follows: HTML CSS
1614977830
GiGs
Pro
Sheet Author
API Scripter
I've changed the earlier code, try that. However, it may still look like it's not working, because of your CSS. I havent examined the CSS (I try not to do much with that), but I deleted all the CSS and with the adjusted code above, it was now working. You likely need to create whatever value the CSS is looking for, for it to be working properly.
It works perfectly. Thanks yet again!
1614979070
GiGs
Pro
Sheet Author
API Scripter
Great!