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 Cards and Chatsettattr

Can someone tell me how to get  !setattr --sel --mod --Strength|5  to work in script cards?  I got other macros like Token Mod/Roll20AM to work but no matter how I type this in it don't work   !scriptcard  {{    --@SetAttr _sel _HP|100   --@ChatSetAttr _sel _HP|100 }} I tried those and they don't work.
1623710249
David M.
Pro
API Scripter
You need a vertical bar after the script name, and SetAttr should be all lowercase setattr (latter is independent of scriptcards). Try this:   --@setattr| _sel _HP|100
1623710538

Edited 1623711254
Ok I got it to recognize it, but even with a token with a character sheet selected it gives me this. Errors No target characters. You need to supply one of --all, --allgm, --sel, --allplayers, --charid, or --name. I got it to work using   !scriptcard  {{    --@setattr| _name @{Target|token_name} _HP|100 }} Thanks David for the fast response it was much apricated.
1623714250
David M.
Pro
API Scripter
Hm, the line I wrote with "_sel" should work - I had tried it in a test game. Did you have a token selected when you ran the macro?
1623716010

Edited 1623716153
I did, I wanted it to target anyway so it worked out. Is there a way I can target the "targets" Max HP to do math and Target the same one to set the new HP without it asking for targets 2 times? !scriptcard  {{    --=Calculation| @{Target|token_name|bar1|max}  + @{Healing Spell|Modifier}   --+| Increased Max HP to [$Calculation] @{Healing Spell|Rounds} for Rounds    --@act|-1 2 _HP UP    --@setattr| _name @{Target|token_name} _HP||[$Calculation] }}
1623755844
David M.
Pro
API Scripter
You can use the --#targetToken command to later reference any of the token or character attributes of the target token as described in the wiki. Token properties have the t- prefix, so the properties you are looking for are t-name and t-bar1_max. Here is a simple example showing how those are referenced: !script {{ --#targetToken|@{target|token_id} --+name|[*T:t-name] --+bar1_max|[*T:t-bar1_max] }} If you don't want the target token image showing up at the top of your card (the default behavior when you use --#targetToken), then just add the following line somewhere in your macro:   --#emoteState|0
Awesome, I really appreciate the quick answers David!