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

Why don't tokenMod sendChats work?

I'm calling these functions from a case/switch. (Example below) When I do so, the roll20AM scripts work perfectly. The tokenMod ones do nothing at all. Yes, I've wrapped it all in an onReady. The scripts work, unless they are sendChats for tokenMod. ________________________    function ObsDet(toggle){         if(toggle === "on"){             sendChat("SYSTEM","api","!token-mod --ids -NiUuLERR0k00TKbcBUo --set layer|objects");             sendChat("SYSTEM","api","!token-mod --api-as --ids -NiUuLERR0k00TKbcBUo --set layer|objects");             sendChat("SYSTEM","api","!roll20AM --audio,play|OBJ DETECTED");             sendChat("api","api","!roll20AM --audio,play|Beeping");             sendChat("SYSTEM","api","!token-mod --api-as --ids -NiyJkQufZE-vGhsfxOq --set layer|objects");         }         if(toggle == "off"){             sendChat( "SYSTEM" "API","!token-mod --ids -NiUuLERR0k00TKbcBUo --set layer|gmlayer");             sendChat( "SYSTEM" "API","!token-mod --ids -NiyJkQufZE-vGhsfxOq --set layer|gmlayer");         }     }
Doh! Older version. Ive removed the "SYSTEM", parts
1700159234
The Aaron
Roll20 Production Team
API Scripter
TokenMod by default does not allow players to use the --ids argument (so they can't change details on tokens they don't own.  The API is like a player, so by default, can't control anything.  You can tell it to act like a specific player with --api-as: --api-as  <playerid> -- Sets the player id to use as the player when the API is calling the script. If the player is a GM, it will be able to access anything.  (I see you have --api-as in some of your commands, but you aren't passing a player id) You can also turn on Players Can IDs in the help or by running this command once: !token-mod --config players-can-ids|on But note that then your players will be able to target other tokens that they don't control.
1700171801
timmaugh
Forum Champion
API Scripter
If you don't want to enable the players-can-ids setting (because you don't want to allow your players to do that, too), you can install the MetaScriptToolbox. SelectManager (part of the toolbox), can select an ID (bypassing the need to pass the --ids arg to TokenMod), and it can be configured to re-supply the playerid and who properties of the message object, and it already comes defaulted to re-supply the set of selected tokens (though that can be changed). You'd want to configure it to re-supply the playerid, at least, since it will require you to be a GM to select something on the GM layer. Configure it by running this command once: !smconfig +playerid Then you can add syntax like this to your command line: {&select  -NiyJkQufZE-vGhsfxOq} The command to move the token from the GM layer to the objects layer would require a little bit more... that one would look like this: {&select  -NiyJkQufZE-vGhsfxOq, +layer=gmlayer} In  your command line, it would look like: sendChat( "SYSTEM" "API","!token-mod --ids -NiyJkQufZE-vGhsfxOq --set layer|gmlayer {&select  -NiyJkQufZE-vGhsfxOq} "); ...and... sendChat("SYSTEM","api","!token-mod --api-as --ids -NiyJkQufZE-vGhsfxOq --set layer|objects {&select  -NiyJkQufZE-vGhsfxOq, +layer=gmlayer} "); Every sendChat like this would need an appropriate selection statement (because script-generated messages don't have a set of selected tokens -- unless SelectManager creates one)... just make sure that your token ids match, of course.
Hey all, I really appreciate it. This forum is amazing, and makes me wish I knew how to code better. This game is now a teaching tool! Basically, I'm using these scripts on a spaceship's combat radar screen. Token mod would be moving the caution indicators from the gm layer to the token layer and back again, depending on what args i send from the macro. Players wouldn't have tokens to move around, but will just have some macros available in their character sheets that allow them to do ship commands. In fact, they wouldn't even interact with this screen directly. They'll just look at it like a console. I'm going to grab a dummy player account with a character as their ship. I'll use --api-as for the gunner to shoot as the ship, for example. Heaven help me when I try to get the ship's gunner to shoot other ships. I'm figuring a script that pulls the NPC ship tokens and lists them in a dropdown to end as args (likely to never be more than 3 on the screen, and usually just 1). So the players can ID is a good choice I think for now. I suspect there will be a version 16.7 before long, and it might well include SelectManager for a variety of reasons. Can't thank you enough. Legends I tell ya.