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

Scriptcards, Concentration and SelectManager

I'm trying to call the updated Concentration API from Aaron from inside a Scriptcards macro.  Concentration API requires a token to be selected and simply uses the !concentation SpellName.  It is automatically triggered when a repeating spell from the character sheet is used (which I'm not doing in this case). But I'm not sure if Concentration needs to list SelectManager as a dependency.  Or if they just won't work.  I can use Token-Mod to manually add the Concentration statusmarker, but the Concentration script does a little more by tracking whether a character is Concentrating on any spells, prompts (or makes) the Concentration save if any damage is taken and notifies if they start Concentrating on a different spell.  So, I'd like to use the Concentration script if possible. But simply adding !concentration Haste !scriptcards {{ blah blah }} doesn't work. Nor does adding --@concentration Haste or  --@forselected|concentration  in the Scriptcards macro
1626837034
timmaugh
Pro
API Scripter
Concentration should work just fine with SelectManager. While it is possible that a few smaller scripts are built in such a way where metascripts won't work, Concentration isn't one of them. I can tell you that I perused that Concentration script, and it looks like it doesn't just use the selected token, it uses the playerid, too (to make sure the player who sent the message can control the token they have selected). The playerid is one of the things that is lost when you have an API (like ScriptCards) call another API (like Concentration). To make that particular bit work, you need to configure SelectManager to not only hand back the selected tokens but the playerid, too. You can turn that on with this command: !smconfig +playerid And double check that both the playerid and selected properties are set to be returned to the api-generated message with this command: !smconfig You should see both properties listed. Once you have that, I believe the ScriptCards syntax you're looking for is: --@concentration|Haste With the appropriate configuration to SelectManager, that should work.
1626837856
David M.
Pro
API Scripter
Would still need a forselected in there, right? So something like this (after updating the config)? --@forselected|concentration Haste
1626840133
timmaugh
Pro
API Scripter
Sooo... what *should* happen is that SelectManager tracks the tokens selected for the most recent user-generated message, and then keeps handing them off to api-generated messages until it encounters another user-generated message, whereupon it stores that new set of selected tokens. (There are ways to change the selected tokens with {& select... } or {& inject ... }  , but that doesn't matter right at the moment.) The point is that even just running the Concentration script from within ScriptCards *should* trigger the handing-back of tokens. forselected goes one step further and gives the tokens back one at a time. If you have a single token selected, there is virtually no difference (maybe little bit of extra time for the forselected version). One other thing that bears mentioning is that forselected defaults to re-attaching ALL three properties that are changed for an API-generated message (playerid, who, and selected tokens). It figures if YOU are launching the forselected call to launch a Concetration call (for instance), then  of course you want the properties returned as if you were running the Concentration script once for each token by hand. The tricky thing is that by embedding forselected in a ScriptCards macro, you have to think about what is in those three properties when SC launches forselected. What does it know about in order to hand them back? When ScriptCards is run (user-generated), the properties are: selected: 1 token who: timmaugh (GM) playerid: -M1234567890abcdef Then it launches forselected. That is an API-generated message, so the properties are: selected: undefined who:  playerid: API forselected will pass on the three properties, but they aren't the values we want (not the user values we started with). That's where SelectManager still needs to be configured to help itself and return not only the selected tokens to the forselected top message, but also the playerid... that way the properties at the time forselected starts iterating the call look like this: selected: 1 token who: playerid: -M1234567890abcdef Then forselected can hand those properties off to the downstream script it is calling.
1626888887

Edited 1626889041
After setting and confirming PlayerID is returned using !smconfig +playerid !smconfig I tried using this syntax in the Scriptcards macro:  --@concentration|Haste but still doesn't work.  It IS firing off the Concentration script now, but it calls up the concentration scrip config, as if I had used !concentration with no token selected.  So, it still doesn't see the selected token. Closer, but not quite there. I did try some alternates which also did not work: --@concentration --@forselected|concentration _Haste --@forselected|concentration timmaugh said: Concentration should work just fine with SelectManager. While it is possible that a few smaller scripts are built in such a way where metascripts won't work, Concentration isn't one of them. I can tell you that I perused that Concentration script, and it looks like it doesn't just use the selected token, it uses the playerid, too (to make sure the player who sent the message can control the token they have selected). The playerid is one of the things that is lost when you have an API (like ScriptCards) call another API (like Concentration). To make that particular bit work, you need to configure SelectManager to not only hand back the selected tokens but the playerid, too. You can turn that on with this command: !smconfig +playerid And double check that both the playerid and selected properties are set to be returned to the api-generated message with this command: !smconfig You should see both properties listed. Once you have that, I believe the ScriptCards syntax you're looking for is: --@concentration|Haste With the appropriate configuration to SelectManager, that should work.
1626889298
David M.
Pro
API Scripter
Have you tried this? Underscores are only required if the subordinate script uses double-dash delimiters. --@forselected|concentration Haste
Unfortunately, no luck there either.  --@forselected|concentration triggers the concentration API config (as if no token were selected) and --@forselected|concentration Haste gives an error message NO TOKENS No selected tokens to use for that command. Please select some tokens then try again.
1626891185
timmaugh
Pro
API Scripter
I will see if I have some time to try to recreate this. BTW, I patched a bug in SM yesterday regarding timing issues... what version on you on? I had hoped my version would hit the 1-click, but the merge hasn't happened yet. For now, you can get the latest version in my repo . The latest version should be 1.0.8. It should report the version in your script log console.
I'm using 1.0.7 from the OneClick.  I'll get 1.0.8 installed this afternoon and report any findings.  Thanks for looking into this Tim.
I'm getting the same behavior using 1.0.8 as I did 1.0.7 --@concentration (or --@forselected|concentration) opens up the concentration API config (like no token was selected) --@concentration Haste (or --@forselected|concentration Haste) gives the error: No selected token to use for that command. Please select some tokens then try again.
1626922393
timmaugh
Pro
API Scripter
So, this works for me... I have: SelectManager v1.0.8 (from my repo, 1-click is pending) Concentration v0.1.14 (from your link) ScriptCards v1.3.1 (from 1-click) And with those installed, I run: !script {{   --@concentration|Haste }} And I get the status marker and the chat text... It works for me both if I have ZeroFrame installed/enabled and if I do not. The only difference between our scripts is likely the version of ScriptCards, and possibly the complexity of your macro. I know the ScriptCards in the 1-click is a few generations behind the copy Kurt has on his development Gist. Can you share what version you have, and the macro you are using?
1626954030
David M.
Pro
API Scripter
Interesting, Tim. So has SelectManager always had this functionality (retaining a single selected token without the need for a "forselected"), or is it relatively new? When we first started using SM with scriptcards, it seemed like forselected was always recommended. I suppose it could be that the scripts we were mostly interested in all could be used with multiple selected tokens (like Spawn, token-mod, etc.), so forselected was the safest choice to handle all use cases?
1626959267
timmaugh
Pro
API Scripter
David M. said: Interesting, Tim. So has SelectManager always had this functionality (retaining a single selected token without the need for a "forselected"), or is it relatively new? Yep... in fact, this was the original thrust of SM, to hand-back these three properties to all API generated messages. Later, the forselected functionality was added on to take the same command line and handle the tokens one at a time so that you utilize differentiated token information... like setting some attribute based on the value of a field, but where it's different for each token. I think originally the whole idea of what SM did was esoteric enough that getting command lines working was the whole goal... not necessarily getting people to understand. Eventually the understanding would come. Same with forselected... it was probably suggested for specific cases where I thought there would be more than one token that needed to take some action, but didn't make a big deal of the difference between that and straight SM behavior. *shrug emoji*
1626969284

Edited 1626970125
I have Scriptcards 1.3.1 from the Oneclick, SelectManager 1.0.8 (from your site) and Concentration 0.1.16 (not sure why I have a later version, but I did reload 0.1.14 and get the same results.  "-=> TokenMod v0.8.71 <=-  [Sun Jul 18 2021 21:20:08 GMT+0000 (Coordinated Universal Time)]" "--- Initialized Carry Tokens ---" "-=> ChatSetAttr v1.10 <=-" "-=> GroupCheck v1.12 <=-" "-=> TokenNameNumber v0.5.14 <=-  [Wed Jun 16 2021 00:39:50 GMT+0000 (Coordinated Universal Time)]" "SpawnDefaultToken v0.21 initialized." "SpawnWIP Offset: 7817" "-=> ScriptCards - 1.3.1 by Kurt Jaegers Ready <=- Meta Offset : 9512" "-=> TableExport v0.2.4 <=-  [Mon Dec 16 2019 20:45:32 GMT+0000 (Coordinated Universal Time)]" "-=> TokenLock v0.2.8 <=-  [Fri May 22 2020 23:37:22 GMT+0000 (Coordinated Universal Time)]" "Radar v0.11 initialized." "RadarWIP Offset: 13233" "-=> libTokenMarkers v0.1.1 <=-  [Wed Dec 30 2020 02:10:29 GMT+0000 (Coordinated Universal Time)]" "  > Loaded 251 Token Markers." "-=> GroupInitiative v0.9.35 <=-  [Mon Oct 12 2020 13:45:47 GMT+0000 (Coordinated Universal Time)]" "-=> ApplyDamage v1.2 <=-" "5E OGL Resting in Style is ready! Select chars, then: !short-rest and !long-rest" "Concentration Ready! Command: !concentration" "ŦŦ SelectManager v1.0.8, 2021/7/20 ŦŦ -- offset 19266" I do get the same result as you when I use  !script {{   --@concentration|Haste }} But I believe that is because the token is never "unselected".  When you select a target, it unselects the token and Concentration sees it as not selected.  What do you get when you use this? !script {{   --#sourceToken|@{selected|token_id}   --#targetToken|@{target|token_id}   --@concentration|Haste }}
Confirmed that it is the Target that is creating the issue.  If I remove the target and replace everything in the script with selected, it works.  When using target, the Concentration doesn't see the source token selected.  Not sure if this is a timing issue or something deeper.  So, this works, but only for spells that you cast on yourself.   Using Target: Removing Target and only using Selected
1626978783
timmaugh
Pro
API Scripter
On, my phone, so this will be short... but this is a known limitation. This is where you will need to use the {&select @{selected|token_id}. That Will preserve the first selected token to be in the tokens that are selected for the message when the API is processing it.
timmaugh said: On, my phone, so this will be short... but this is a known limitation. This is where you will need to use the {&select @{selected|token_id}. That Will preserve the first selected token to be in the tokens that are selected for the message when the API is processing it. Bam!  Got it.  I just added a dummy variable to the script before the target token is defined: --=NotUsed|{&select @{selected|token_id}} And got it!  Thanks Tim!
1627004264
timmaugh
Pro
API Scripter
Excellent! Just FYI, that SM select construct will be gone by the time Script Cards runs... SelectManager will eat it before the message ever gets to SC. So you don't even have to assign it to a variable that you never use. =D Glad you got it working!