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- help with affecting multiple character ids

Im trying to use Select Mananger with the ChatSetAttr script to edit multiple character sheet attributes at the same time. In this case for experience, I'm starting from this command

!forselected setattr --charid @{selected|character_id} --mod --experience|?{amount|0} 

which does work, it runs the script the correct number of times depending on number of tokens selected, however it applies all the experience to the first selected character. The script says to replace  @{selected|...}  with at{selected|...}  because Roll20 takes @{selected|token_id} and gives the token or character id of just the first selected token. Select Manager is supposed to read the replacement at{selected|...} but it is not for me when using this command, 

!forselected setattr --charid at{selected|character_id} --mod --experience|?{amount|0} 

Using this just gives the error

Errors

Invalid character id at{selected|character_id}.
No target characters. You need to supply one of --all, --allgm, --sel, --allplayers, --charid, or --name.

saying that Select Manager is not reading this correctly unless Im just not understanding the correct syntax for this. Ive tried this with no other scripts installed except other Meta-Toolbox scripts (zeroframe, muler, fetch, mathops,etc.) which shouldn't interfere with it so Im not sure what Im missing.


December 24 (3 years ago)
timmaugh
Pro
API Scripter

Hey, Inky... 

Sorry, this was a case of the documentation not getting updated at some point along the way when the syntax changed. You should be able to do what you want to do changing this formation...

at{selected|character_id}

...to...

at(selected|character_id)

(changing the braces to parentheses).

I have updated the instructions in the thread to reflect this.

Since you have ZeroFrame installed, if you want to see this working (short of including ChatSetAttr), you can select a handful of tokens and run this command:

!forselected(^) at(selected|character_id) {^&simple}

That should kick out the associated character IDs for the selected tokens, one after another, to the chat.

Post back if you still have trouble.

December 24 (3 years ago)

Edited December 24 (3 years ago)

Hey thanks a whole bunch works perfectly. While I have you maybe you could help me with another little issue Im having? I want to use Select Manager to set multiple tokens' health bars to their npc rolled hp stat. Ive been doing it individually with this command

!token-mod {{
  --on 
    showplayers_bar3
  --set 
bar1_value|0
bar1_max|0
    bar2_link|npc_ac
    bar3|[[@{selected|npc_hpformula}]]
    compact_bar|compact
}}

The relevant portion is for bar3, With Select Manager I have 

!forselected token-mod {{
  --on 
    showplayers_bar3
  --set 
bar1_value|0
bar1_max|0
    bar2_link|npc_ac
    bar3|at(selected|npc_hpformula)
    compact_bar|compact
}}

This appears to only pull the first part of the npc_hpformula attribute which is the number of dice, unrolled (eg. "2d8+2" shows only "2d8" in token bar). I used your zeroframe command with npc_hpformula to see that it is pulling the full attribute from multiple tokens correctly. I guess it has something to do with the inline roll of the dice. I did see another post, by you I think actuallly, where you provide some solutions to this. 

!forselected token-mod --set bar1|[[3d6]]

can be rewritten as 

!forselected token-mod --set bar1|[\[3d6]\] {& eval} null() {& /eval}

which does work nicely. Though Im not sure how to go about using this with a character sheet attribute, in which the inline roll is a part of.

December 26 (3 years ago)
timmaugh
Pro
API Scripter

Hey, Inky... just wanted to say I'm looking at this. It's pointing to an error in SelectManager which I'm trying to address at the same time. Hopefully I'll be able to get you a solution soon.

December 30 (3 years ago)
timmaugh
Pro
API Scripter

The tricky part about this one is that forselected runs as a standard script... meaning that there is a metascript processing opportunity before it dispatches all of the outbound TokenMod calls. Then there is another metascript processing opportunity for each of those dispatched TM calls individually (they are each their own message).

Take all of that together, and what you realize is you have to preserve the ability to call an individual attribute for each selected token, and you need to defer the processing of the inline roll until AFTER that attribute has resolved in EACH outbound message. So we have to not only defer our inline roll for the outbound TokenMod messages, we have to disguise it so it isn't detected in the metascript processing that happens BEFORE forselected even gets the message. That is, we don't even want our deferral detected until the TM message is dispatched! (Otherwise ZeroFrame will attempt to un-defer it and process the roll.)

An individual attribute (like the npc_hpformula) can be 'late'-retrieved by using the at(...) formation, like you did:

at(selected.npc_hpformula)

Then a roll can be deferred...

...by turning this...
[[ ... ]]
...into...
[\][\] ... \]\]

But that we need to disguise that so that it is only detected (and serves to defer the roll) once the message is sent for TokenMod and the attribute has been fetched from the specific/selected token. To do that, we'll use a forselected deferral character:

forselected(^)

...and we'll insert it in such a way as to break up the character string that would make those roll deferrals otherwise detectable:

[^\][^\] ... \^]\^]

That lets the roll pass unmolested until forselected receives the command line... much as the at(...) formation holds off on returning the fetched attribute until the script is ready to process each token. With forselected's deferral character removed, the message sent to TokenMod contains just the inline roll deferral and the Fetch command (to get the roll equation from the attribute). Those happen in the correct order, and the roll resolves in the TokenMod message.

Hopefully that makes sense. I can explain more if you like. Either way, here is a working example of just setting differentiated bar3 values for selected NPC tokens.

!forselected(^) token-mod --set bar3|[^\][^\]at(selected.npc_hpformula)\^]\^]

Wow! I only partially followed the explanation but it is working as I wanted. Thanks again for the help.