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

Select manager -am I just stupid?

I've installed the selectmanager API but can't figure out how to use it. I read and re-read the instructions and search the forum and look at examples but for some reason can't wrap my feeble brain around this one or get it to work. It seems I only need to add forselected followed by a space between the ! and the API in question (I mainly use tokenmod and setattr). But it never works. Literally cut and paste the example from the instructions and nothing. Other than install the API is there something I'm supposed to do?
Some scripts are written in a way that they only affect a single token. Select manager allows you to run those scripts to work with several selected tokens.  It's also written in a way so that previously written scripts can easily incorporate Select Manager as a dependency so that the script users don't have to do anything other than also load Select Manager.
Here are a couple of scriptcards that I have that use Select Manager. This one uses setattr !scriptcard {{ --#title|Combat Maneuver --=Dices|@{selected|repeating_resource_$0_resource_left}-1 --#leftsub|Dices Left: [$Dices] --=DiceTotal|@{selected|repeating_resource_$0_resource_left|max} --#rightsub|Total Dice: [$DiceTotal] --@forselected+|setattr _silent _sel _mod _repeating_resource_$0_resource_left|-1 --=SaveDC|8+@{selected|pb}+@{selected|strength_mod} --=SuperiorDice|1d6 --=Maneuver|?{Which One?|Trip,1|Parry,2} --C[$Maneuver.Total]|1:Trip|2:Parry --:Trip| --+Action Type:| After you hit with an weapon attack. --+Plus:|[$SuperiorDice] damage. --+Strength Save DC:|[$SaveDC] --+Failed Save:| Target is knocked prone. --^Final| --:Parry| --=Parry|[$SuperiorDice]+@{selected|dexterity_mod} --+Action Type:| Reaction --+Parry:| You parry [$Parry] damage from the incoming attack. --:Final| }} This one uses token-mod. !scriptcard {{ --#title|Vision/Light --=VisionType|?{VisionType|Normal,1|DarkVision 60ft,2|DarkVision 120ft,3|Candle,4|Torch/Cantrip,5|Hooded,6|Campfire,7|Blind,8} --C[$VisionType.Total]|1:One|2:Two|3:Three|4:Four|5:Five|6:Six|7:Seven|8:Eight|9:Nine|10:Ten --:One| --+Vision/Light Type:| Normal Vision --@forselected+|token-mod _on bright_vision _off night_vision emits_bright_light emits_low_light has_directional_bright_light has_directional_dim_light --^Final| --:Two| --+Vision/Light Type:| Dark Vision 60 ft --@forselected+|token-mod _on night_vision _set night_vision_distance|60 night_vision_effect|Dimming dimming_start|0 --^Final| --:Three| --+Vision/Light Type:| Dark Vision 120 ft --@forselected+|token-mod _on night_vision _set night_vision_distance|120 night_vision_effect|Dimming dimming_start|0 --^Final| --:Four| --+Vision/Light Type:| Candle --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|5 low_light_distance|5 --^Final| --:Five| --+Vision/Light Type:| Torch/Cantrip --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|20 low_light_distance|20 --^Final| --:Six| --+Vision/Light Type:| Hooded Lamp --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|30 low_light_distance|30 --^Final| --:Seven| --+Vision/Light Type:| Campfire --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|15 low_light_distance|15 --^Final| --:Eight| --+Vision/Light Type:| Blind --@forselected+|token-mod _off bright_vision night_vision emits_bright_light emits_low_light has_directional_bright_light has_directional_dim_light --:Final| }} Hope this helps you.
1618138172
David M.
Pro
API Scripter
I'm sure it has more features that I'm not using, but the primary draw for me is the ability to call an api script that requires selected/target tokens from another script (like Jarred alluded to and Snow shows examples of above). Without SM, the api "forgets" which tokens were selected/targeted and the subordinate script may fail (depending on the script).
Jarren K. said: Some scripts are written in a way that they only affect a single token. Select manager allows you to run those scripts to work with several selected tokens.  It's also written in a way so that previously written scripts can easily incorporate Select Manager as a dependency so that the script users don't have to do anything other than also load Select Manager. Yes. That's what the documentation says.
David M. said: I'm sure it has more features that I'm not using, but the primary draw for me is the ability to call an api script that requires selected/target tokens from another script (like Jarred alluded to and Snow shows examples of above). Without SM, the api "forgets" which tokens were selected/targeted and the subordinate script may fail (depending on the script). Yes. But why doesn't it work? I'm trying to apply bless to all selected tokens. My custom sheet has a Bless attribute.  !forselected setattr --sel --Bless|1 and nothing happens.
I don't use scriptcards (powercards loyalist). But I can understand some of this. Is the coding different? Snow said: Here are a couple of scriptcards that I have that use Select Manager. This one uses setattr !scriptcard {{ --#title|Combat Maneuver --=Dices|@{selected|repeating_resource_$0_resource_left}-1 --#leftsub|Dices Left: [$Dices] --=DiceTotal|@{selected|repeating_resource_$0_resource_left|max} --#rightsub|Total Dice: [$DiceTotal] --@forselected+|setattr _silent _sel _mod _repeating_resource_$0_resource_left|-1 --=SaveDC|8+@{selected|pb}+@{selected|strength_mod} --=SuperiorDice|1d6 --=Maneuver|?{Which One?|Trip,1|Parry,2} --C[$Maneuver.Total]|1:Trip|2:Parry --:Trip| --+Action Type:| After you hit with an weapon attack. --+Plus:|[$SuperiorDice] damage. --+Strength Save DC:|[$SaveDC] --+Failed Save:| Target is knocked prone. --^Final| --:Parry| --=Parry|[$SuperiorDice]+@{selected|dexterity_mod} --+Action Type:| Reaction --+Parry:| You parry [$Parry] damage from the incoming attack. --:Final| }} This one uses token-mod. !scriptcard {{ --#title|Vision/Light --=VisionType|?{VisionType|Normal,1|DarkVision 60ft,2|DarkVision 120ft,3|Candle,4|Torch/Cantrip,5|Hooded,6|Campfire,7|Blind,8} --C[$VisionType.Total]|1:One|2:Two|3:Three|4:Four|5:Five|6:Six|7:Seven|8:Eight|9:Nine|10:Ten --:One| --+Vision/Light Type:| Normal Vision --@forselected+|token-mod _on bright_vision _off night_vision emits_bright_light emits_low_light has_directional_bright_light has_directional_dim_light --^Final| --:Two| --+Vision/Light Type:| Dark Vision 60 ft --@forselected+|token-mod _on night_vision _set night_vision_distance|60 night_vision_effect|Dimming dimming_start|0 --^Final| --:Three| --+Vision/Light Type:| Dark Vision 120 ft --@forselected+|token-mod _on night_vision _set night_vision_distance|120 night_vision_effect|Dimming dimming_start|0 --^Final| --:Four| --+Vision/Light Type:| Candle --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|5 low_light_distance|5 --^Final| --:Five| --+Vision/Light Type:| Torch/Cantrip --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|20 low_light_distance|20 --^Final| --:Six| --+Vision/Light Type:| Hooded Lamp --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|30 low_light_distance|30 --^Final| --:Seven| --+Vision/Light Type:| Campfire --@forselected+|token-mod _on emits_bright_light emits_low_light _set bright_light_distance|15 low_light_distance|15 --^Final| --:Eight| --+Vision/Light Type:| Blind --@forselected+|token-mod _off bright_vision night_vision emits_bright_light emits_low_light has_directional_bright_light has_directional_dim_light --:Final| }} Hope this helps you.
1618145679

Edited 1618146680
timmaugh
Pro
API Scripter
You've gotten a lot of good info already, Peacekeeper, and it sounds like you've read through the documentation, so let's see if we can't figure out what's going wrong. If you just run !smconfig ...into the command line, you should get a small message like this: That tells you which of the three message components are auto-inserted when SelectManager detects an API generated message. More importantly for us, it tells you that your SM is installed properly and enabled. Do you get this message? EDIT: Those settings are assumed to be "on" for a forselected call... so we shouldn't have to change them to make a forselected work. The point is that if SM is installed and you have a functioning sandbox, you should get this message, so let's start there.
1618154152
David M.
Pro
API Scripter
Peacekeeper B said: I'm trying to apply bless to all selected tokens. My custom sheet has a Bless attribute.  !forselected setattr --sel --Bless|1 and nothing happens. Syntax looks correct. I just tried it in a test game and it worked properly with multiple tokens selected. Hopefully it's a settings thing. Timmaugh's on the case so I'm sure it will get figured out.  Are you calling it from another script (like Powercards), or are you just trying the single line above in a separate collections macro?
At this point I'm trying to just call it from a generic macro or chat input. Eventually I would like to use it with a powercard.
1618168788
timmaugh
Pro
API Scripter
Did you try the !smconfig I suggested? What was the result?
That would require being near my computer today. Sunday is family day. 
Snuck away and checked. Only comes back with selected. 
1618176671
timmaugh
Pro
API Scripter
Peacekeeper B said: Snuck away and checked. Only comes back with selected.  Sneaky troubleshooting, FTW! Ok, it doesn't matter that you only see selected... that's what will happen for a *normal* API message (not a !forselected). That's the way SelectManager ships, with only that one property enabled. Just the fact that you got a message is what matters for now -- that tells me SelectManager is there and you have a functional sandbox. When you get a chance, post the full macro you're using that isn't working, and what you see when you run it.
!power {{ --bgcolor|#f1c232 --name| @{selected|token_name} casts Prayer on Allies }} !forselected setattr --sel --MiscCombat|1 --MiscDamage|1 --MiscSave|1  !forselected token-mod --set statusmarker|blue ****** The last two commands (the !foreselected ones) are outside the powercard. It is currently working. Except the tokenmoddoesn't work and the powercard name references the last token selected not the caster.
1618198211
timmaugh
Pro
API Scripter
You need an 's' on the end of 'statusmarker' for that token-mod call to work: !forselected token-mod --set statusmarkers|blue Everything worked for me once I made that change. Bear in mind, there is a known bug where the Roll20 system randomly drops one or more of the command-lines in a multi-command macro... and your macro is three individual calls. Testing your case, even though I had the correct/corrected syntax, I actually witnessed it drop the token-mod call once (so nothing happened). The other times, it worked perfectly. As for how powercards references the last selected token rather than the caster, that is the way the @{selected...} formation resolves in a command line where there are multiple tokens selected. I'm not familiar enough with the PC syntax requirements to know if there is something else you can do, but I can tell you that I'm working on a meta-toolbox that should give you a couple of options for in-line tinkering to obtain the correct character.
Appreciate all the help. I'm just trying to use this for multiple targets at once. Can players use it as well?
1618231782
timmaugh
Pro
API Scripter
There is no reason players can't use this macro, too, the only thing is -- as it is written -- you would have to trust them to select the tokens in the correct order so that the proper token would be slotted in as the caster. Narrator's voice: He could not trust his players. Of course, if you use a targeting statement, you'll lose your array of selected tokens. In that case you can do a hardcoding of names, and give everyone their own version of the macro (with their name pre-populated), or you can offer a query to let them pick their own... Or you can keep an eye out for the Meta Toolbox (about to be released) and use the Fetch script to retrieve data -- in this case, from the speaker (your players' characters' tokens). =D