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

Create a link to a Macro with sendChat

Hi all !! I'm trying to launch an API from another API : In my case, I want to change the orientation of a token when it PV reachs 0. But, when  I'm sending "!token-mod --set orientation|+180" to the chat with sendChat, it doesn't  work. Then, I create a macro that doing that, and I try to launch this macro from the API with sendChat , but one more time, it doesn't work. So, as suggered by Aaron in a post, I tried to create a link to the macro in the chat with "sendChat("","[click](#macro)")", but I don't know why, the  link doesn't work... :/ Help me plz :)
1611756298
Kurt J.
Pro
API Scripter
Camille M. said: Hi all !! I'm trying to launch an API from another API : In my case, I want to change the orientation of a token when it PV reachs 0. But, when  I'm sending "!token-mod --set orientation|+180" to the chat with sendChat, it doesn't  work. Then, I create a macro that doing that, and I try to launch this macro from the API with sendChat , but one more time, it doesn't work. So, as suggered by Aaron in a post, I tried to create a link to the macro in the chat with "sendChat("","[click](#macro)")", but I don't know why, the  link doesn't work... :/ Help me plz :) Calling APIs from other APIs via sendChat doesn't populate the "selected" portion of the chat message (because API scripts can't select tokens), so you'll need to use the --ignore-selected and --ids options for the token-mod call to know what token to work with.
Hi Kurt ! Thx for your help ! But I already try this ! This is what I code : "sendChat("","!token-mod --ignore-selected --ids " + char_id + " --set rotation|+180");" But still not working :/
I think that TokenMod only works on Token IDs, not Character IDs. I'm not sure what char_id is pulling from your script, or if TokenMod does allow Character IDs (which would likely affect all tokens linked to that character sheet if that's the case). From the TokenMod help file: --ids takes token ids to operate on, separated by spaces. Also it could be that you need to adjust your config to allow 'players' to use IDs, as when the command is passed to TokenMod it won't know that it's the GM commanding and ignore it, unless you turn on 'Players Can ID': --ids -- Each parameter is a Token ID, usually supplied with something like @{target|Target 1|token_id}. By default, only a GM can use this argument. You can enable players to use it as well with --config players-can-ids|on.
1611762686
The Aaron
Roll20 Production Team
API Scripter
--ignore-selected isn't really going to be needed here since there won't be anything selected.  You'd really only need that when you are running a command that you are targeting a specific id with, and might have something selected unintentionally. It will actually take character_ids as well.  It will find all tokens that represent that character and operate on them.  I need to update that part of the documentation, but you can see it listed here: --current-page  -- Only modifies tokens on the calling player's current page. This is particularly useful when passing character_ids to  --ids . --active-pages  -- Only modifies tokens on pages where there is a player or the GM. This is particularly useful when passing character_ids to  --ids . Orientation isn't a setting that TokenMod knows. Take the ! off the front and see what is actually being sent to chat, it might make the error apparent.
Hi Aaron, nice to see U here :) Here is what I send to the chat (! off) : token-mod --ignore-selected --ids -M2e-kDFFAVwbRNcXUcq --set rotation|+180 Note that It works when I paste it in the chat with the !
1611765264
The Aaron
Roll20 Production Team
API Scripter
Oh, you need to add --api-as: This is what I code : "sendChat("","!token-mod --api-as "+msg.playerid+" --ignore-selected --ids " + char_id + " --set rotation|+180");" And probably make sure you have Player Can IDS turned on.
1611765355
The Aaron
Roll20 Production Team
API Scripter
TokenMod by default only lets GMs use the --ids argument.  The API is not a GM, so --ids won't get used.  If you pass it a player id and that player is a GM, it will let --ids work.  Or if you set Player Can IDS, it will let anyone use --ids
Yeah, that's it ! I forgot to set the players-can-ids option to true !  Is this permanent ? Or should I set it with all new tokens ? Whatever, Thx a lot The Aaron :)
1611784885
The Aaron
Roll20 Production Team
API Scripter
You only have to set it once, it's global.