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

Using ChatSetAttr to deal damage or heal PCs and NPCs

Good evening everyone !  I have been using ChatSetAttr to automatically spend the mana of my PC's spell so that they don't have to, and I wanted to push it a bit further, by making in it so that when they cast a spell, they have to select the enemy token, validate, and they automatically dill the damage rolled to the enemy. However, while the mana consumption works very well, it appears that dealing rolled damage doesn't work the way I thought it would, and I am surely missing something. This is what I am stuck with :  Is it the fact that the roll is inline ? Or inside a template ? I am new to the API and scripts so I come for help D:
1531442387
GiGs
Pro
Sheet Author
API Scripter
Its because its in the rolltemplate. API commands, that start with !, need to be the first thing on their line.
1531443104
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Inside the roll template, you'll want that API command to be in an API Command button: {{damage=[Button Name](!API_Command)}} That will cause a clickable button to appear in the template, which will actually run the command. You cannot have a raw command do anything in a roll template.
1531464784
Jakob
Sheet Author
API Scripter
keithcurtis said: Inside the roll template, you'll want that API command to be in an API Command button: {{damage=[Button Name](!API_Command)}} That will cause a clickable button to appear in the template, which will actually run the command. You cannot have a raw command do anything in a roll template. That won't allow OP to roll damage in the roll template, however... I'm thinking about coming up with a way to allow this kind of thing with ChatSetAttr, though.
keithcurtis said: Inside the roll template, you'll want that API command to be in an API Command button: {{damage=[Button Name](!API_Command)}} That will cause a clickable button to appear in the template, which will actually run the command. You cannot have a raw command do anything in a roll template. Jakob said: keithcurtis said: Inside the roll template, you'll want that API command to be in an API Command button: {{damage=[Button Name](!API_Command)}} That will cause a clickable button to appear in the template, which will actually run the command. You cannot have a raw command do anything in a roll template. That won't allow OP to roll damage in the roll template, however... I'm thinking about coming up with a way to allow this kind of thing with ChatSetAttr, though. G G said: Its because its in the rolltemplate. API commands, that start with !, need to be the first thing on their line. Well, thank you all for the insightful comments, I guess I don't know enough about scripts to know what could or could not be possible :/ Anyway, It's just a quality of life thingy, and ChatSetAttr has already helped me manage my spell costs, which is huuuuuuuuuuge. Thanks again Jakob !
1531482684
Jakob
Sheet Author
API Scripter
So I did a thing ...