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

Fill character sheet after dropdown choice

1689172009
.Hell
Sheet Author
Hey folks, I want to fill the whole character sheet after the user has chosen an item of a dropdown and clicked a button. This is used for fast npc creation. What would be the best way to add this to a character sheet? My current plan is to add a data object for each NPC, store them in a list and fetch the data when the button is clicked. Anyone got any better ideas? Thanks for the discussion :)
1689179105
GiGs
Pro
Sheet Author
API Scripter
It sounds like your approach is the best approach. Just match the data to the actual attribute naes and run a single setAttrs. I've used the method on a much smaller scale (not a full character) but its definitely feasible to do it that way.
1689197878
John D.
Pro
Sheet Author
+1 I have become very fond of this approach, though different use cases, and recommend storing the data flat so the formatting is the same for your setAttrs() call. Even store all the data in a single JSON separated by NPC type/named, and just grab that chunck. 
1689199527
GiGs
Pro
Sheet Author
API Scripter
John D. said: +1 I have become very fond of this approach, though different use cases, and recommend storing the data flat so the formatting is the same for your setAttrs() call. Even store all the data in a single JSON separated by NPC type/named, and just grab that chunck.  Agreed. If you can use the same keys on the object as attribute names its ideal. But if you have any repeated sections, it'll be a bit trickier.
1689225103
.Hell
Sheet Author
Yeah, I have to sets of repeating sections. So I have to handle it via code anyway