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

Referencing new tokens without using target or selected

Is there any way to summon tokens or change token sides while simultaneously referencing the incoming token ID.
1545710978
GiGs
Pro
Sheet Author
API Scripter
I'm uncllear what you're asking. If you use @{selected|token_id} or @{target|token_id} you have access to all the properties of a token. If you need to access multiple tokens, you can use @{target|first|token_id}, @{target|second|token_id}, @{target|third|token_id}, etc (with first, second, third in this case being replaceable with any identifying label you want to use. You'll be prompted to select as many tokens as you have individually identified.
Thank you for your reply! An example with tokentool would be switching the side of a rolltable token by specifying its token_id. Is there any way to pull that new token_id as I switch its side?
1545712238
GiGs
Pro
Sheet Author
API Scripter
What specifically are you trying to achieve? what do you need the token_id for?
1545712570
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You can switch a rollable token programatically with the API script Tokenmod. You can get a token's id by the aforementioned @{selected|token_id} or @{target|token_id}. You can specify the token whose sides you want to change with Tokenmod by referencing its token id. But I have a feeling this isn't quite what you are asking. Could you describe it a bit more, including what you mean by "pull that new token_id". Do you mean pull the number value, or actually pull a fresh token onto the tabletop by referencing the token id? The former is possible as previously described; the latter is possible using the Summon script.
Yeah, sorry I haven't been clear. An exact example of what I would do with the summon token and chat set attribute scripts would be to summon a new token, while storing that new token's ID on a character sheet.
1545718852
GiGs
Pro
Sheet Author
API Scripter
I'm not familiar with a summon token script. Are you saying, you want to summon some creature or entity that hasnt yet been created using another script, then grab the token's id and using chatsetattr store it in the character sheet? Presumably so you can resummon that specific creature again? IF I'm understanding you correctly, that explains why you wanted a way to do it without selected or target. I think you'll need another script for this, which would probably replace chatsetAttr in your workflow. You'll need a script to scan the tokens that exist, using the name from the summon monster script, to grab its token id. Is that what you're going for?
Yeah! That's exactly what I'm trying to do. GiGs said: I'm not familiar with a summon token script. Are you saying, you want to summon some creature or entity that hasnt yet been created using another script, then grab the token's id and using chatsetattr store it in the character sheet? Presumably so you can resummon that specific creature again? IF I'm understanding you correctly, that explains why you wanted a way to do it without selected or target. I think you'll need another script for this, which would probably replace chatsetAttr in your workflow. You'll need a script to scan the tokens that exist, using the name from the summon monster script, to grab its token id. Is that what you're going for?
1545721338

Edited 1545721615
GiGs
Pro
Sheet Author
API Scripter
Is there a reason you need the exact token's id? Can you not just summon a generic copy of it again? Edit, better question: What do you plan on using the token_id for, once it has been saved? I'm asking these questions to narrow down specifically what you need, so we can give the best advice on how to go about it.
I use tokenmod to keep track of status symbols and I wanted players to summon images of weapons that would also track weapon specific statuses. I wanted the token_id as a way to to bind each weapon to its owner so they don't have to select or target it at any point.
1545737025
GiGs
Pro
Sheet Author
API Scripter
There's a custom status script, that allows you to use custom images as status icons, for example image of a sword, shield, etc. If all you need is an icon that is attached to a token to show what weapon they are using, that might be a better solution. It's in the one-click script installer if that would be useful.
Thanks for the suggestion! I've used that one in the past but the piece I'd be missing is the ability to place status markers on the weapon images that would be separate from the players token. For example, I'd like to be able to show that a given weapon has a stat of 2 and a player has the same stat of 1 by marking each with a 2 / 1 of the same status marker.
1545830606

Edited 1545830618
GiGs
Pro
Sheet Author
API Scripter
In that case, probably the best way is to examine how the summon monster script works, a tweak of it would be able to grab the token id of the token it summons and save it to your character sheet. However, I think there is a problem here. I'm not totally sure, but I think each time you create a token, it's id is randomly regenerated. If that's the case, you won't be able to use the method you are hoping to re-summon the token.  i have to go now, but I'll try to think of a good way to handle this. Though if the weapons each have a character sheet, you can summon them from there by name, not id.
So I'm a goon and I think I went about the wrong way of solving this! I didn't know token-mod could already find a token through character_ID and since the summon script makes the summoned token represent a character sheet by default, I think I have a way to reliably reference the weapon without ever needing its token_ID. Thank you so much for all of your help on this!