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

token_mod querying for statusmarker?

1710720980

Edited 1710721278
Midnite Oil
Pro
Marketplace Creator
Greetings, I am writing some macros for reactions the player can take. For example, Cutting Words. I've already got it checking the class_resource to make sure the bard has some bonus actions available and to determine the die roll based on the base_level. However, I also want to display a message if they're already used their reaction (I have a reaction toggle that will toggle the Yellow status marker to indicate a character has used its reaction and I use OnMyTurn to clear that marker). But I want Cutting Words to be able to query the selected token for the Yellow status marker. I've tried the following but it always returns true even if the marker isn't there: !script {{ --#title|Cutting Words --?@{selected|class_resource} -eq 0 |[ --+|[c][#ff0000]You are unable to use cutting words again until you complete a long or short rest[/#][/c] --]| --?@{selected|token_id} --@token_mod -ids @{selected|token_id} --get statusmarkers#yellow -eq 1 | [ --+|[c][#ff0000]You have already used your reaction this round[/#][/c] --]| --?@{selected|class_resource} -eq 0 | [ --=bardicInspirations|@{selected|class_resource} - 1 --+|[c]You have [$bardicInspirations] bardic inspirations remaining[/c] --@setattr|_charid @{selected|character_id} _class_resource|[$bardicInspirations] _silent --?@(Aust|base_level) -ge 15 |=inspirationDie;1d12 --?@(Aust|base_level) -lt 15 |=inspirationDie;1d10 --?@(Aust|base_level) -lt 10 |=inspirationDie;1d8 --?@(Aust|base_level) -lt 5 |=inspirationDie;1d6 --+|[c]Subtract[$inspirationDie] from the roll![/c] --@token-mod --ids @{selected|token_id} --set statusmarkers#yellow --]| }}
Since you are using ScriptCards  already, ScriptCards can check status markers without the need to TokenMod. --#sourceToken|@{selected|token_id} --?"[*S:t-statusmarkers]" -inc "yellow"| ScriptCards can also perform  Object Modification  if you wanted ScriptCards to do what you are using ChatSetAttr and TokenMod for as well. 
1710726609

Edited 1710787404
timmaugh
Pro
API Scripter
Also, Fetch can get a lot of different information about a token status right in your existing command line (even for another script): @(selected.status.yellow) Which, in the ScriptCards syntax, I believe would look like: --?@(selected.status.yellow) -eq 1 | [ But others can correct me on that...
1710786049
Midnite Oil
Pro
Marketplace Creator
Thanks!
1710787543
Midnite Oil
Pro
Marketplace Creator
I tried a little test and I'm getting a 0 for the yellow status marker whether I set it on the token or not !script {{ --#title|Test Status Marker --#sourceToken|@{selected|token_id} --=yellowStatusMarker|"[*S:t-statusmarkers]" inc "yellow" --+Yellow Status Marker| [$yellowStatusMarker] }}
1710787695
Midnite Oil
Pro
Marketplace Creator
and using fetch !script {{ --#title|Test Status Marker --#sourceToken|@{selected|token_id} --=yellowStatusMarker|"[*S:t-statusmarkers]" inc "yellow" --+Yellow Status Marker| [$yellowStatusMarker] --=fetchedmarker|@(selected.status.yellow) --+Fetched yellow status marker|[$fetchedmarker] }}
1710788265
Midnite Oil
Pro
Marketplace Creator
I'm clearly not understanding something here. I tried adding a foreach loop to display all the markers: !script {{ --#title|Test Status Marker --#sourceToken|@{selected|token_id} --=yellowStatusMarker|[*S:t-statusmarkers] inc "yellow" --+Yellow Status Marker| [$yellowStatusMarker] --=fetchedmarker|@(selected.status.yellow) --+Fetched yellow status marker|[$fetchedmarker] --%loop|foreach;[*S:t-statusmarkers] --+marker|[$loop] }}
1710789044

Edited 1710789416
My response was to update your conditional to not use token-mod and use ScriptCards. !script {{ --#title|Cutting Words --#sourceToken|@{selected|token_id} --?@{selected|class_resource} -eq 0 |[ --+|[c][#ff0000]You are unable to use cutting words again until you complete a long or short rest[/#][/c] --]| --?"[*S:t-statusmarkers]" -inc "yellow"|[ --+|[c][#ff0000]You have already used your reaction this round[/#][/c] --]| --?@{selected|class_resource} -eq 0 | [ --=bardicInspirations|@{selected|class_resource} - 1 --+|[c]You have [$bardicInspirations] bardic inspirations remaining[/c] --@setattr|_charid @{selected|character_id} _class_resource|[$bardicInspirations] _silent --?@(Aust|base_level) -ge 15 |=inspirationDie;1d12 --?@(Aust|base_level) -lt 15 |=inspirationDie;1d10 --?@(Aust|base_level) -lt 10 |=inspirationDie;1d8 --?@(Aust|base_level) -lt 5 |=inspirationDie;1d6 --+|[c]Subtract[$inspirationDie] from the roll![/c] --@token-mod --ids @{selected|token_id} --set statusmarkers#yellow --]| }} If you want to use the Meta script Toolbox like timmaugh suggested, that will probably work too. My post was merely about updating your conditional to check with ScriptCards. It wasn't about setting a roll variable EDIT: As for your last post about trying to loop over your status markers, the  statusmarkers property of a Graphic object  is a comma separated string. It is not an array. !script {{ --#title|Test Status Marker --#sourceToken|@{selected|token_id} --~Marker|string;split;,;[*S:t-statusmarkers] --%i|1;[$MarkerCount];1 --+Marker|[&Marker[&i]] --%| }} That ScriptCard will output all markers on the selected token. In ScriptCards, foreach loops need arrays. For loops can iterate over numbers like in the above example. This splits the statusmarkers on commas. Loops also need to be closed hence the `--%|` at the end there.
1710792049
timmaugh
Pro
API Scripter
You can check the value of the individual status with the toolbox like this: !The value is @(selected.status.yellow).{&simple} You should not get any return if you have the marker but no value (that is, you should only see "The value is ." hit the chat). You should only get a 0 if you have a 0 for the marker value. Also, if you want to just test if a token is marked with a status, you can use the ".is" property of the Fetch syntax: @(selected.status.yellow.is) That will return "yes" or "no" depending. Finally, if you want a quick way to just see all of the markers on a token, Fetch gives that to you with: @(selected.markers)