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

How to use character name to get token_id?

I'm trying to figure out how to use a character's name (or a token's name, or whatever is necessary) to get the token_id of that character. I see references to things like @{Character Name|token_id}, but this does not work for me. It just puts "Valanthe|token_id" in the chat, if I type "@{Valanthe|token_id}". Any guidance?
1533780261
The Aaron
Pro
API Scripter
So, from the API, you can get all the tokens that represent a given character: let tokens = findObjs({type:'graphic', represents: character.id}); But there isn't a way to do it from the client side with an attribute reference. 
I guess this question is a macros question, rather than an API question! Sorry about that. Thanks!    
1533820740
Ziechael
Forum Champion
Sheet Author
API Scripter
If it is just the id you want you can put the token on the VTT and then use @{selected|token_id} or @{target|token_id} What is the full name of the character in question?
1533821150
The Aaron
Pro
API Scripter
Also, what is the problem you're trying to solve here?  There might be another way to think about it.  One thing to be aware of is that every token (with one rare exception) has a unique id for each copy on each page.  You won't be able to just hardcode something to the token id as it will be different every time you drag something out.
A character has a magic sword called Dawnbringer, which can shed light in a 15-foot radius, and can be extended to 30-foot radius. I wanted to make a macro that didn't require selecting or targeting that character's token, and which could use the Torch API to change the radius of light. I was also just trying to validate the references to being able to use character name in a macro. I haven't been able to confirm that it works at all. I just wanted to save the player time, so they didn't have to select or target a token, because it's always the specific character who has that sword. The character in question has the name "Jakk Hiperon", and their token has the name "Jakk". Neither @{Jakk Hiperon|token_id} or @{Jakk|token_id} worked. I've given up now, and just made it so the player has to select his own token to use the macro, but there are a bunch of references in the macros wiki to using character name in this way, and I don't see any evidence that it's possible.
1533825475

Edited 1533825533
The Aaron
Pro
API Scripter
Ah, you can do this quite easily with TokenMod: !token-mod {{ --set ?{Sword Light|15' Radius,light_radius#15 light_dimradius#30|30' Radius,light_radius#30 light_dimradius#60} --ids @{ Jakk Hiperon |character_id} }} Just change  Jakk Hiperon  to the name of the character.  Running this will prompt for what radius to use, then set all tokens representing that character to have the selected light properties.  Adjust as needed for dim radius, and who can see it, etc. You will need to be sure that Player can --IDS is turned on in the !token-mod --help .