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 call token properties other than Attributes?

Hey there, First time posting, so apologies if I've done anything wrong. I searched the forums but I couldn't find anything resembling the issue I'm having. I wish to use the side number of a token as a variable in a macro. I only know how to call attributes, and I have no idea how to call any other token properties (such as size, name, etc.) Am I missing something obvious? Or is this just not possible? Thank you, Rory
1601486573

Edited 1601486686
David M.
Pro
API Scripter
This will require use of the api. The token-mod script is the go-to for accessing these properties. EDIT - you can access token name without the api using: @{selected|token_name}
1601486795

Edited 1601486926
Thanks for the reply. TokenMod is great, but I thought it was only for modifying properties. Can it also be used to call those properties as well?
1601486831
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Some are callable: @{selected|token_name} @{selected|bar1} Others, like aura, vision, and unfortunately, side number are not. Most of these things are open to the API, though. There may be scripts which can report these, though working them into a macro as a usable value might be a bit more involved.
Hmm, that's a shame. :( Does anyone know of a script that can do this? I've found so many wonderful API scripts on here, but I've sadly not had any luck making my own.
1601492178

Edited 1601492191
David M.
Pro
API Scripter
Oooh, I missed that you were trying to pass the values to a macro. Even API scripts can't do this. If you wanted to use a value such as token side, the script would have to do all the work including output to chat, so it would be very specific. What are you trying to do? Keith, depending on this answer, is it possible that InsertArgs might be able to do something magical? I noticed you were playing around with it a bit, but I haven't had a spare 60hrs to wrap my head around it :)
I'm trying to make a Token Ability that does something different depending on which side the token is on. The specific example is actually quite complicated, it changes the side of a second token depending on the side of a third token. But I've got a workaround for that so it's not important.
1601561734
David M.
Pro
API Scripter
Could you create a workaround by: Only change the token side via token-mod api script, but simultaneously update a custom attribute via the ChatSetAttr script that you could reference directly from a macro/ability using standard @{CharName|AttributeName} or @{AttributeName} syntax? So your token changing macro would contain both !token-mod blah blah and !ChatSetAttr blah blah. Rory C. said: I'm trying to make a Token Ability that does something different depending on which side the token is on.
1601562263

Edited 1601562285
The Aaron
Roll20 Production Team
API Scripter
Some clarifying questions: Is the token ALWAYS associated with a Character? Will you need to have different behavior on different tokens for the same character based on the side of that token? Are you using all the bars on the token or could one be repurposed to hold the side index? Could your logic be encompassed in an API script instead of a macro?
1601563264
David M.
Pro
API Scripter
Good questions, Aaron! I see where you are going with these. Almost like you've been doing this for a while ;) Seems like the bar value method (if available) would be the easiest while also allowing for tokens with no attached character sheet.
1601564801

Edited 1601564824
David M. said: Could you create a workaround by: Only change the token side via token-mod api script, but simultaneously update a custom attribute via the ChatSetAttr script that you could reference directly from a macro/ability using standard @{CharName|AttributeName} or @{AttributeName} syntax? So your token changing macro would contain both !token-mod blah blah and !ChatSetAttr blah blah. The Aaron said: Some clarifying questions: Is the token ALWAYS associated with a Character? Will you need to have different behavior on different tokens for the same character based on the side of that token? Are you using all the bars on the token or could one be repurposed to hold the side index? Could your logic be encompassed in an API script instead of a macro? Funnily enough, this is pretty much the workaround I came up with, thanks. I made separate characters for each token, and used a combination of TokenMod and ChatSetAttr to control the token sides while setting an Attribute on a token bar to the value of the side. It was clunky and complicated, but it seems to work. This isn't the first time I've wanted to do this though, so a more general solution would be appreciated if it exists. Unfortunately, I haven't been able to wrap my head around API scripting. I've installed a bunch from the in-built library (including many from yourself Aaron, thank you SO much for that!) and I've done a lot of cool stuff with them, but that's as far as I've been able to get.