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

Does anyone know how to access the character sheet information in a character from the API?

I can't find this particular feature anywhere in the documentation.
1403065470
Lithl
Pro
Sheet Author
API Scripter
Er, what is it that you're wanting to access?
Weapon statistics. They all appear to have the same name.
In example, I have two weapons on the Pathfinder community sheet. I want to make an !attack command, and select the first weapon. I don't know how to differentiate between the two.
1403066534
Chad
Sheet Author
Hi Trent, The way most sheets are programmed, you can't. If the sheet is setup to be expandable (You can click +more to add more weapons) It is specifically stated that it won't be consistent which row is #1 and which is #2. However, if the number of rows is constant, you can check the sheet source to see what their numbers are and access them that way. Chad
The only way to really do this is with manual labor. Designate the first weapon in the repeating field to be the "equipped weapon" and you will also know what attributes to use. Not perfect, but workable.
Trent, I know on the D&D5 character sheet these are a repeating field. With each iteration there is usually a line indicator. For example, it may be weapon_0_damage for the first row and then weapon_1_damage for the second row, etc. Then you just need to know which row you want and use the appropriate weapon_X_damage you need. Does that help any?
I added some information on this to the API documentation, see the "Working with Character Sheets" section on the API:Objects page. <a href="https://wiki.roll20.net/API:Objects" rel="nofollow">https://wiki.roll20.net/API:Objects</a>
1403102185
Sam M.
Pro
Sheet Author
First, you can't use "getAttrByName" because that only works for static fields. Second, you'll probably have to pass in either the index of the row or the field name itself. Repeating fields begin indexing at 0 and increment upwards. So your first weapon will be "repeating_weapon_0_name" etc. Third, you'll have to do a manual search for the weapon based on the passed in parameters with some error checking in case the attribute doesn't exist. It's totally doable as I currently call my repeating weapons' ammo fields to decrement them when bows are shot and stuff.