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

[Dev] Determining length of array-like attributes

1591485022
Magnar S.
Pro
API Scripter
Additional resources in the OGL 5E character sheet are accessed using identifiers like these: repeating_resource_$0_resource_left repeating_resource_$0_resource_right repeating_resource_$1_resource_left repeating_resource_$1_resource_right How can I determine if there are any, and in that case how many of these are present? I can access the field directly using: getAttrByName(charId, 'repeating_resource_$0_resource_left'); However, this logs an ERROR to the console if there are none.
1591488601
GiGs
Pro
Sheet Author
API Scripter
You'd use the findObjs function here:&nbsp; <a href="https://wiki.roll20.net/API:Objects#findObjs.28attrs.29" rel="nofollow">https://wiki.roll20.net/API:Objects#findObjs.28attrs.29</a> to get all te attributes of the character, then filter down to those in the format&nbsp; repeating_resource_ (id) _resource_left That'll give you all the rows, and you can extract the ids. The actual row ids for repeating section are UUIDs, which look something liKe -35GHTU6445 &nbsp;- you need to use that format for the id for most operations. Once you have an array of the ids, you can do whatever you need to.
1591517863
Magnar S.
Pro
API Scripter
Thank you, that makes sense.