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

@{target} syntax for id?

1443274000
Lucian
Pro
API Scripter
Hi, I was wondering if it's possible to get either a token or a character id using the @{target|<attribute>} syntax. @{target|token_name} seems to be sort of magic, since "token_name" doesn't appear to be a property on any object or an attribute of the character (at least if you list the attributes of the character through the API). I'm trying to do stuff with API buttons that work on a target or selected token and it would be easier and nicer to pass an ID through to the API rather than sending a token_name and then going all round the houses to look it up - assuming that it's even unique. Cheers, Lucian
You probably have more success if you ask this in the API section of the forum
Take a look at <a href="https://wiki.roll20.net/API:Objects" rel="nofollow">https://wiki.roll20.net/API:Objects</a> for all the object properties you can work with.
1443287716
Lucian
Pro
API Scripter
Quatar said: You probably have more success if you ask this in the API section of the forum Ok. I asked here because strictly the feature I'm interested in isn't specific to the API, even if my motivation for wanting it is. If I don't get anywhere here I'll take the question over there. Mark G. said: Take a look at <a href="https://wiki.roll20.net/API:Objects" rel="nofollow">https://wiki.roll20.net/API:Objects</a> for all the object properties you can work with. Yeah, I've looked at that page, but I'm not sure that it's relevant to the @{selected|} or @{target|} syntax for chat/macros. What you put after the pipe character generally seems to be an attribute, except in the case of "token_name" which seems to be magic. Writing @{selected|_id} or @{selected|id} doesn't work, nor does accessing other object properties using this syntax. I was just hoping that there was a way to make it return an id, though... Cheers, Lucian
@{selected|token_id}
1443289099
Lucian
Pro
API Scripter
HoneyBadger said: @{selected|token_id} Fantastic, thanks. I feel stupid now - I thought I'd tried that but I'd had a brain freeze and typed {@selected|token_id} by mistake. Doh! Helpfully @{selected|character_id} works as well :-) Lucian
1443300873
Lithl
Pro
Sheet Author
API Scripter
Yes, token_name, character_name, token_id, and character_id are "magic" attributes. If you use "attr_character_name" as the name of an input field on a character sheet, the player also has the ability to change the actual name of the character in the journal.