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

Get all values of character sheet fieldset

Ok, so I've hacked my way through this problem but I'm hoping someone here can guide me to a better way to handle this. I'm trying to read all properties from a fieldset on a custom character sheet, however i can't seem to target any attribute that will return an object of all the values. I'm resorting to building the properties names by hand until one breaks, which feels terrible to do. Is there a better, cleaner way to do this? The HTML <fieldset class="repeating_moves"> <input type="text" name="attr_condition" /> </fieldset> The JS Hack //Using a while loop because there is no theoretical upper limit on i function getConditions(char){ var conditions = []; var i = 0; var no_error = true; while(no_error){ var condition = getAttrByName(char.id, "repeating_moves_"+i+"_condition"); if(condition){ conditions.push(condition); i++; } else { no_error = false; } } //Pleaseing UI message for no conditions if(conditions.length < 1){ conditions.push("No conditions, go do something interesting"); } return conditions; }
1435098267

Edited 1435098376
The Aaron
Pro
API Scripter
Something like this is probably what I would do: var char = /* got from somewhere */; var conditions = filterObjs( function(o){ return o.get('type') === 'attribute' && o.get('characterid') === char.id && /repeating_moves_\d*_condition/.test(o.get('name')) ; }); See: <a href="https://wiki.roll20.net/API:Objects#Finding.2FFilt" rel="nofollow">https://wiki.roll20.net/API:Objects#Finding.2FFilt</a>... for details on filterObjs()
+5 internets for you today, sir
1435098628
The Aaron
Pro
API Scripter
Yeah! I was getting tired of wielding this +3 Internets... bounded accuracy and all.. =D