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

[Script] Using TokenMod and a custom OnTurnStart script?

Hello there! I am pretty new to roll20 and still learning all the macros and such. I found a very nice api addon - TokenMod - that I use to mark one of my player's barbarian's rage as a token marker with turns remaining, same with his reckless attack in our d&amp;d 5e session. I wanted to make it so that the rage remaining updates itself and the reckless attack marker gets removed on turn start so that it's more automated and I found a useful script under this link: <a href="https://app.roll20.net/forum/post/6608405/script-onmyturn-activate-an-ability-in-the-context-of-a-token-when-its-turn-occurs/?pageforid=6619049" rel="nofollow">https://app.roll20.net/forum/post/6608405/script-onmyturn-activate-an-ability-in-the-context-of-a-token-when-its-turn-occurs/?pageforid=6619049</a> The script allows me to create an ability for a token that gets fired on the start of its initiative order, which works good unless I try using TokenMod with it. I'm not sure if it is anyhow possible to achieve what I want, if not that's okay, but maybe I'm just doing something wrong? This is the ability I use for the turn start: !token-mod --ids @{selected|token_id} --set statusmarkers|fluffy-wing Fluffy wing is used as a test marker, because it's fluffy. When I use the token-mod function outside of the OnMyTurn ability it works wonderful. Here nothing happens. I tried finding a solution slightly, so first I found, that in this ability, the @{selected|token_id} returns a value "Undefined". When I checked the token id by hand and put it there like that: !token-mod --ids -M9OVa3x5xtwWNSBkvQ6 --set statusmarkers|fluffy-wing It still yielded no result. Does the above mean that what I want is not possible to achieve? Any help will be appreciated, thanks in advance! Cheers!
1592225349
The Aaron
Roll20 Production Team
API Scripter
It's likely because you don't have the Players Can IDS setting on. By default, TokenMod doesn't let players use the --ids option as they can change characters they don't control. The API is treated like another character, and that's the character that runs commands fkr OnMyTurn. See if that setting is off in the help, and turn it on if it is: !token-mod --help
Hello! Thanks for the quick reply. I toggled it and the TokenMod works when the token ID is put there manually. But the function I linked still returns token ID as undefined. Is there a possibility to work that out somehow? Or do I need to make some custom function that will set a character stat as the token ID and then just read that on turn start maybe? Thanks in advance
1592318405
The Aaron
Roll20 Production Team
API Scripter
Hmm... That should work.&nbsp; OnMyTurn will convert @{selected|...} references to their values for the current token in the turnorder.&nbsp; Try taking the ! off and see what gets sent to chat.&nbsp; Make sure it has the token_id and that the token_id matches what you expect.
Hello again! It works marvelously! Thanks very much!