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 .
×

Selection problem

Hello everyone, I have a script that takes as input "selected|dexterity_mod" and "target|ac". I have a macro that calls the script with those inputs, but what I have to do to make it work is annoying. I have to select token, launch macro, select target and select token again. If I don't select the token again (after I selected the target) it won't work. How can I make it so that I have to select the token only once? Without having to select it again after choosing target? Thanks in advance, I hope I was clear
1635454448
The Aaron
Roll20 Production Team
API Scripter
I would suggest using two target statements instead.  @{target|Source|dexterity_mod} and @{target|Target|ac} But that might not be ideal either, depending on what you're doing.  If you could do this as an ability on a character instead of a macro, you could just write @{dexterity_mod} and not worry about selected. 
1635454466
Andreas J.
Forum Champion
Sheet Author
Translator
You should be able to patch it by using SelectManager API to make sure the selection carries over between API parts.
1635476699
timmaugh
Roll20 Production Team
API Scripter
Yep, Andreas is absolutely correct about SelectManager being able to help. Even though a message with a targeting statement doesn't have selected tokens (which is what is leading to your long workaround), statements retrieving information from the FIRST selected token will still resolve... so you can get: @{selected|dexterity_mod} If that is in your command line, you'll get the value returned from the selected token's character. On the other hand, if your script requires the token to actually be selected because IT is going to go to the character sheet and get the dexterity mod, then you can use the above trick to return info from the first token, but feed it into a SelectManager statement in your command line: {& select @{selected|token_id} } Put that anywhere in your existing command line, and you'll end up with a token being selected (as far as the message and your script are concerned), even if you have a targeting statement, too.
Thanks everyone for your replies! I'll definitely look into selection manager, for the moment I've fixed the problem by writing it as an ability instead of a macro removing the selection altogether! Thanks Aaron for the suggestion