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

Problem with Scriptcards and SetAttr

I have tried everything I can think of, but I can't get setattr to increment the two fields. Any thoughts? !scriptcard {{ --#title|@{selected|token_name} makes a Panic Check --=PC1|1d6 --+Roll|[$PC1] --=Stress|@{selected|character_stress} --+Stress|[$Stress] --?[$PC1] -gt [$Stress]|>Panic --+|@{selected|token_name} did not panic. [$PC1] > [$Stress] --^Final| --:Panic| --+|@{selected|token_name} panicked! [$PC1] > [$Stress] --=PC2|[T#Panic-Check] --+|[b][$PC2.tableEntryText][/b] --@token-mod| _set _bar1_value|+1 _bar2_value=[$PC2] --vtoken|@{selected|token_id} nova-frost --+Stress|[$Stress] --:Final| }}
1695346377
GiGs
Pro
Sheet Author
API Scripter
I don't see any mention of setAtts in your macro and don't know which two fields you want to increment. I'm not a scriptcards guru, so maybe I'm just missing something that is already there. I wouldn't ask here though. There's a dedicated scriptcards thread - ask in there, you are guaranteed to be seen by people who use ScriptCards and know the syntax.
Whoops. Not setattr, token-mod.
1695348700

Edited 1695348718
timmaugh
Forum Champion
API Scripter
When a script calls a script (like you have ScriptCards calling TokenMod), there is no selected token for the subbed-out-call. The "player" who owns that message is the API (the Script Moderator), and that player never has any tokens selected on the VTT. You have 2 options:  1) you can install SelectManager (it comes auto-defaulted to "give back" the selected tokens in a case like this) or 2) you can pass TokenMod the id of the selected token in the --ids argument: --@token-mod| _set _bar1_value|+1 _bar2_value=[$PC2] _ids|@{selected|token_id} For this one, you must either be a GM, or TokenMod must be configured to allow players to use the ids argument (check the documentation for more information).
OK. I implemented SelectManager, but I don't see any change. I revised the TokenMod line to  --@forselected| _token-mod _set _bar1_value|+1 _bar2_value=[$PC2] but now I get no results at all.
1695352934
timmaugh
Forum Champion
API Scripter
You don't need the forselected handle in there... SelectManager would make the original TokenMod command work without any alterations. To be clear, adding forselected can work, too, but the reason you got no results from the line as you wrote it was because in a forselected line, the downstream handle ("token-mod") does not need to be prepended with the underscore. That is, it is not an argument to forselected, needing double hyphens (which become the underscore in ScriptCards).
1695372568
Kurt J.
Pro
API Scripter
When using token-mod and specifying IDs, make sure you have configured token mod to allow players to use IDs
I have tried all the suggestions above, but  I can't get token-mod to increment the two fields. !scriptcard {{ --#title|@{selected|token_name} makes a Panic Check --=PC1|1d6 --+Roll|[$PC1] --=Stress|@{selected|character_stress} --+Stress|[$Stress] --?[$PC1] -gt [$Stress]|>Panic --+|@{selected|token_name} did not panic. [$PC1] > [$Stress] --^Final| --:Panic| --+|@{selected|token_name} panicked! [$PC1] > [$Stress] --=PC2|[T#Panic-Check] --+|[b][$PC2.tableEntryText][/b] --vtoken|@{selected|token_id} nova-frost --@token-mod| _set _bar1_value|+1 _bar2_value=[$PC2] _ids|@{selected|token_id} --=Stress|@{selected|character_stress} --+Stress|[$Stress] --:Final| }}
This token-mod line looks slightly off to me. I usually lead with _ids before the _set and you don't need a pipe after _ids. Also you don't need an underscore before each bar value. I'm also not sure about the equals sign without a pipe for bar2_value. Can you try something like: --@token-mod|_ids @{selected|token_id} _set bar1_value|+1 bar2_value|[$PC2] That looks more like the token-mod lines I use in my ScriptCards
1695400543
timmaugh
Forum Champion
API Scripter
Yes, Joshua is right. I can confirm that with his corrections of the TokenMod line, it works for me. It works with the ids argument supplied as he has done, and it also works without that argument but with SelectManager installed: --@token-mod|_set bar1_value|+1 bar2_value|[$PC2] And it works if you insert the forselected: --@forselected|token-mod _set bar1_value|+1 bar2_value|[$PC2] But that's really not necessary if you're only working on a single token.