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

Macro to select tokens via name

I have pro and APIs. I use tokenmod a lot. I use tokenmod for locking movement with the simple macro "!token-mod --flip lockMovement" However, what I want is a macro that applies this to the same characters (the PCs) without needing to have them all selected. Otherwise its far too clunky to work with free roam and suddenly stopping all of them. Anyone have a way to make this work? If so, can you give an example?
1734276410
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You are looking for a metascript, specifically SelectManager. You can check out the documentation linked on its install page. I'll also see if I can summon the Metamancer himself.
1734281320

Edited 1734281410
If you are happy to use ScriptCards, this works for me.&nbsp; I've ripped it from another script, so may also be able to refine it somewhat, but it also does it without invoking another script !script {{ --/|Script Name : Lock and Free the party --#title|Lock 'em down --#titleFontLineHeight|6 --#bodyfontface|Helvetica --#bodyfontcolor|#220000 --#buttonfontsize|9px --#buttonbackground|#2c0f70 --#buttonfontface|Tahoma --#titlecardbackground|#f6efd6 --#titlefontcolor|#ffa900 --#titlefontsize|1.5em --#titlefontshadow|0 --#titlecardBackgroundImage|url('<a href="https://s3.amazonaws.com/files.d20.io/images/400332587/0KP5KXdZQPyTUBRfOZKVyQ/max.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/400332587/0KP5KXdZQPyTUBRfOZKVyQ/max.png</a>'); background-size: 100% 100%; background-repeat: no-repeat; --#oddrowbackground|#f6efd6 --#evenrowbackground|#f9f14b --#subtitlefontcolor|#f9bb4b --&amp;LockStatus|?{Lock or Unlock|Lock|Unlock} --?[&amp;LockStatus] -eqi Lock|&amp;Status;true|&amp;Status;false --/|Get all tokens on the page into the "alltokens" array --~|array;pagetokens;alltokens;[*C:playerpageid];pc --/|Create the "inRange" array. It will have a blank item in it to begin with, which we will remove later. --~|array;define;inRange; --/|Loop through all of the tokens in "alltokens" --~tokenid|array;getfirst;alltokens --?[&amp;tokenid] -eq ArrayError|endOutput --:loopCheck| --/|Skip targets that are not on the token layer or that don't represent creatures --?[*[&amp;tokenid]:t-layer] -ne objects|continue --/|?"[*[&amp;tokenid]:t-represents]" -ninc "-"|continue --/|If we didn't skip over this part the token is a PC, so add it to the inRange array --~|array;add;inRange;[&amp;tokenid] --:continue| --~tokenid|array;getnext;alltokens --?[&amp;tokenid] -ne ArrayError|loopCheck --/|Remove the dummy first item in the inRange array --~|array;removeat;inRange;0 --/|Loop through the inRange tokens --~tokenid|array;getfirst;inRange --?[&amp;tokenid] -eq ArrayError|endOutput --/| now run through the tokens and present information to DM --:loopDisplay| --!t:[*[&amp;tokenid]:t-id]|lockMovement:[&amp;Status] --+|[*[&amp;tokenid]:t-name] is [&amp;LockStatus]ed --/|Get the next token and continue the loop until we run out. --~tokenid|array;getnext;inRange --?[&amp;tokenid] -ne ArrayError|loopDisplay --:endOutput| --X| }}
keithcurtis said: You are looking for a metascript, specifically SelectManager. You can check out the documentation linked on its install page. I'll also see if I can summon the Metamancer himself. TokenMod can do this directly without SelectManager, but you'll need two macros (or a query to select lock or unlock): !token-mod&nbsp;--ids&nbsp;@{CHARACTERNAME1|character_id}&nbsp;@{CHARACTERNAME2|character_id}&nbsp;@{CHARACTERNAME3|character_id}&nbsp;--on lockMovement !token-mod&nbsp;--ids&nbsp;@{CHARACTERNAME1|character_id}&nbsp;@{CHARACTERNAME2|character_id}&nbsp;@{CHARACTERNAME3|character_id}&nbsp;--off lockMovement
Jarren said: keithcurtis said: You are looking for a metascript, specifically SelectManager. You can check out the documentation linked on its install page. I'll also see if I can summon the Metamancer himself. TokenMod can do this directly without SelectManager, but you'll need two macros (or a query to select lock or unlock): !token-mod&nbsp;--ids&nbsp;@{CHARACTERNAME1|character_id}&nbsp;@{CHARACTERNAME2|character_id}&nbsp;@{CHARACTERNAME3|character_id}&nbsp;--on lockMovement !token-mod&nbsp;--ids&nbsp;@{CHARACTERNAME1|character_id}&nbsp;@{CHARACTERNAME2|character_id}&nbsp;@{CHARACTERNAME3|character_id}&nbsp;--off lockMovement This is looking promising. however, I don't understand it fully. The charactername1 and character_id, what do these represent? Is one the token name and the other the represented player, or something?
1734293615
timmaugh
Pro
API Scripter
Jarren is taking advantage of the fact that TokenMod can utilize either selected tokens (default), token ids, or character ids. He's having you supply character IDs since, from map to map, the tokens that represent those characters would be different, and therefore have different IDs. This formation: @{CHARACTERNAME1|character_id} ...is a Roll20 construction where Jarren wants you to replace "CHARACTERNAME1" with the first character's name. The construction consists of a character identifier (the name), followed by a vertical pipe, followed by an attribute/property you want to return from the character, if found. So if you had a character named Actual Cannibal, you could get his "NormalTuesdayNight" attribute like this: @{Actual Cannibal|NormalTuesdayNight} The metascript solution Keith mentioned earlier would be to install the Metascript Toolbox, and then use the constructions right in the command line with the TokenMod commands. For instance, if you had three characters named Actual Cannibal, Shia LeBeouf, and Volcano Man, you could select them specifically by adding this to your TokenMod line: {&amp;select Actual Cannibal, Shia LeBeouf, Volcano Man} Then your TokenMod line could go back to not needing the --ids argument that Jarren included (that argument is necessary if you are supplying tokens/characters to affect; by using SelectManager we are manipulating the tokens that are selected prior to TokenMod seeing the message, so we don't need the --ids arg). Another option when using the Metascript Toolbox is to supply criteria to a wildcard search. That way, you wouldn't have to update (potentially) a bunch of different commands if your party ever grows/shrinks. That is, this version would work whether you added a character or lost a character because it targets "all characters on the page": {&amp;select *, +pc} You can add that to a TokenMod line that targets selected tokens, and this little syntax will select all the player tokens on the current page (check the documentation for how that is determined if you have a question... I think it is if a non-gm player is listed *first* in the controlledby property of the token).
I see. Thank you for the explanation. I believe I understand it now and also believe I have a working macro now. I have to get a player to test with me to find out but it seemed like it would behave as wanted, before gm status override kicked in. Appreciate the assistance. This is one of the biggest things I wish roll20 just had working. Some platforms, you just press space and all tokens freeze. Super handy for exploration maps.
Kel said: I see. Thank you for the explanation. I believe I understand it now and also believe I have a working macro now. I have to get a player to test with me to find out but it seemed like it would behave as wanted, before gm status override kicked in. I suggest creating a Dummy Account &nbsp;for yourself so you can test out player-facing issues yourself without waiting on another player. TokenMod by default does not allow players to use its commands on tokens they do not control.&nbsp; You can enable TokenMod to be used by players on any token by using this command:&nbsp; !token-mod --config players-can-ids|on&nbsp;