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 .
×

help sheet worker

1646165904
죽화
Pro
Sheet Author
Hi. I'm making a custom character sheet. Most sheet Worker Scripts can be used well. Please show me an easy example of using getSectionIDs. Also, I wonder if sheet:component-drop and setDefaultToken (values) can be used without compendium.
1646171026
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The drop and the setDefaultToken are only usable with a compendium. Admittedly, the drop stuff has no purpose without a compendium. On mobile at the moment, but I'll post an example of getSectionIDs later.
1646182597
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
And, now for the getSectionIDs bit. The wiki has a pretty good write up on how the function works. Essentially it iterates through all of the rows in a given section and calls a callback function that it passes an array of the row IDs. You will always want to use this before you do a getAttrs, as the IDs aren't that useful without also having the information on attributes in those rows. You can build an array of attribute names to get from the IDs. This looks like so: on('change:strength',(event)=>{ getSectionIDs('repeating_inventory',(idArray)=>{ const repeatAttributeNames = idArray.reduce((memo,id)=>{ memo.push(`repeating_inventory_${id}_weight`,`repeating_inventory_${id}_quantity`); return memo; },[]); const getArray = ['strength','strength_mod',...repeatAttributeNames]; getAttrs(getArray,(attributes)=>{ //Do things with your attribute values. }); }); }); If you need to get the row ids for multiple sections, you need to use multiple layers of getSectionIDs. I typically do this by iterating over them via a work queue (aka a burndown pattern). Since you're working on your own custom sheet, you might be interested in following my weekly sheet author tutorial, A Sheet Author's Journey . The next post will be out tomorrow! Hope that helps, Scott