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

CharacterSheet self-reference to API

It seems like the API has plenty of ways to reference the character sheet, but the character sheet doesn't have a good way to reference itself in the UI. For example, right now, I'm building a character sheet with several buttons intended to fire API functions. I do this by building a roll button, and then setting the value to "!Command|@{name}|@{variable}|etc...". The API will then catch that event, split the string, and then use the @{name} to find the character.id using the "findObjs()" function. Then it will read off attributes from the matching sheet and perform logic. The downside of this is that the "@{name}" variable is the attribute that is set on the character sheet. What if the player left it blank? What if the player spelled their name differently on the sheet compared to their bio? What if this name is a duplicate for another character or monster? In my case, the character sheet is actually 7 different types of character sheet depending on what type of thing I'm representing: Character, Creature, Computer, Robot, Vehicle, Spaceship. Some of these shouldn't need a name set on the character sheet. Is there no way to pass the ID of the character sheet on which you pushed the button? This would save about 10 steps, a bunch of wasted cycles, and make the whole mechanism less prone to error.
1431195546

Edited 1431195608
The Aaron
Roll20 Production Team
API Scripter
@{character_id} should give you the character id, which is supplied by Roll20 and will let you use getObj('character',character_id) instead.
Yep, that works. So much easier! Thank you!