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

How can i ensure that an attribute exists?

I tried to use a hidden input field on my charactersheet to store a dummy-variable for the !ammo script because as far as I understood it is not really possible to create a fully fledged dynamic ammunation counter (for fieldset based entries) but the problem is, altough the input field is part of the sheet, the character did not have the attribute yet until I manually added it to the attributes page. Is there a way (by an existing script or macro/etc) to ensure that an attribute exists? When are attributes actually created? On the first input? If so, is there any way to use hidden fields?
1432053426
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
You can give the input a default value like value="0" to insure that it gets populated. Or, when you're doing your calculations you can do (@{attribute}+0)+({@{attribute}+0) to keep it from returning a nil value.