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

[API] Selected tokens, token macro, api calls and @target

1413321603

Edited 1413321652
So, the api. When you use a token macro that includes api chat commands (for example: "!DoStuff"), and that macro is a token macro, the api call will be able to use msg.selected (assuming msg is the message object), to access the token. It would seem fairly obvious that a token macro would produce a selected token. Now, the problem is, that when that same macro includes a call to @{target|something}, the token is deselected before the api recieves the call - no matter the order in which the lines in the macro is written. This seems like a bug, as one would expect the following: !DoStuff <-- call api with currently selected token included in the /em I attack @{target|name} <-- write out the emote, using the target information I understand how this could work behind the scenes, so that it would result in the current behavior, but that does not mean I agree with it. Also, it does not seem unreasonable that a token macro, calling the api, would alway include itself (or the corresponding token) as parameters. - Toke
1413324967
The Aaron
Roll20 Production Team
API Scripter
It is a known issue. I believe most people get by that issue by either passing the character_id and then finding the token based on what page the controlling player is on, or by passing the token_id as a parameter before the @{target} !DoStuff @{character_id} <-- always defined in a token macro /em I attack @{target|name} <-- causes deselection of tokens !DoStuff @{selected|token_id} <-- Evaluated while the token is still selected /em I attack @{target|name} <-- causes deselection of tokens
Thanks for the quick reply. Should solve all my problems for now :)
1413375599
The Aaron
Roll20 Production Team
API Scripter
No worries! BTW, this should technically go in the API forum. :)
Ah. Right. Somehow I didn't realize that there was an API forum, since it's only available to mentors anyway. (Anyone with the ability to do so should feel free to move this thread)
Moving this to the API forum. :)