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

Question About "Grouping"

If you group a load of tokens together, will they have their own "group token id" and be able to be referenced as "@{selected|token_id}" or does it just give you some arbitrary token of the group's token id?
1531628942
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It'll give you an arbitrary token of the group (probably the first or last selected of the group)
1531632047
GiGs
Pro
Sheet Author
API Scripter
Is there any way to iterate through the members of a group?
G G said: Is there any way to iterate through the members of a group? Great question. I'm wondering if it's possible to loop over all the tokens in a group using the API.
1531648164
Jakob
Sheet Author
API Scripter
Kastion said: G G said: Is there any way to iterate through the members of a group? Great question. I'm wondering if it's possible to loop over all the tokens in a group using the API. I believe (correct me) that if you select one member of a group, all will be selected. So for API purposes, the "selected" property of the message object will hold the ids of all tokens in the group, hence you can iterate over them.
Jakob said: Kastion said: G G said: Is there any way to iterate through the members of a group? Great question. I'm wondering if it's possible to loop over all the tokens in a group using the API. I believe (correct me) that if you select one member of a group, all will be selected. So for API purposes, the "selected" property of the message object will hold the ids of all tokens in the group, hence you can iterate over them. Oooo really? Let me test it out and I'll get back to you.
I've done some testing and the functionality of this is pretty wacky. Using the built-in /fx command on a selected group does NOTHING. No FX, no error messages in chat, no indication at all that has even been run. Using the !cfx API command plays the FX on ONE of the grouped tokens. !token-mod worked just fine when specifying "--ids @{selected|token_id} It seems to only work with commands or API script commands that are programmed to take a list of Token ID (Like !token-mod with "--ids" for example) Its use is limited by what scripts support a delimited list of token IDs or if you're so inclined you can modify the script you want to use to support multiple IDs.
1531652353
Jakob
Sheet Author
API Scripter
The reason that this works for TokenMod doesn't have anything to do with @{selected|token_id} ... it works for TokenMod since it uses msg.selected  in the API by default. @{selected|token_id} just gives you the ID of one  of the grouped tokens, as Scott said.
Oh my bad. I was confused by your wording here: So for API purposes, the "selected" property of the message object will hold the ids of all tokens in the group, hence you can iterate over them. I just glossed it over and when I saw "selected" I assumed @{selected|token_id} not msg.selected . Either way regardless of the reason this won't work with all existing scripts and built-in Roll20 commands. I'll have to test any script I want to use on a group of objects and if it doesn't work possibly import the script and modify it to use msg.selected.