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 call works, until wrapped in a roll template

Messing with ChatSetAttr for the first time. Following the examples.. This works fine: !modattr --charid @{target|character_id} --powerpoints| -5 When I put it in a roll template, following the example, this does nothing: &{template:default} {{name=Power Points}} !modbattr --charid @{target|character_id} --powerpoints| -5 {{description= Text}} What am I doing wrong?
1693897895

Edited 1693897948
vÍnce
Pro
Sheet Author
I think you need to include !!! at the end of the script's macro. To do so, write the ChatSetAttr command between the properties of a roll template, and end it "!!!". <a href="https://github.com/Roll20/roll20-api-scripts/blob/master/ChatSetAttr/README.md" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/blob/master/ChatSetAttr/README.md</a> does this work? &amp;{template:default} {{name=Power Points}} !modbattr --charid @{target|character_id} --powerpoints| -5!!! {{description= Text}}
Thanks,&nbsp;vÍnce, that put me close to one that worked.&nbsp; I don't understand why the !!! works in this case since the help file says: If a macro had rolls after the ( !!! ), they wouldn't change any stats on the sheet. What I am calling the help file is the forum post -&nbsp; <a href="https://wiki.roll20.net/Script:ChatSetAttr" rel="nofollow">https://wiki.roll20.net/Script:ChatSetAttr</a>. &nbsp;Helps to read the Read Me. &amp;{template:default} {{name=Power Points}} !modbattr --charid @{target|character_id} --powerpoints| -5!!! {{description= Text}}&nbsp; Did not work, but this did: &amp;{template:default} {{name=Power Points}} !modattr --charid @{target|character_id} --powerpoints| -5!!! {{description= Text}} Thank you for the assist: I need to stop staying up way too late working on this stuff...
1693920456
timmaugh
Forum Champion
API Scripter
Also, if you needed a bit more control over the timing of things, you could use ZeroFrame and run the commands separately but as part of a batch: !{{ &nbsp;&nbsp; !modbattr --charid @{target|character_id} --powerpoints| -5 &nbsp;&nbsp; {&amp;template:default} ({)name=Power Points(}) ({)description= Text(}) }} That would run the ChatSetAttr command first, then the template line. In certain cases, a script like CSA might have an asynchronous process that leads to the next line running before you want it to... in other words, it might run before CSA has had a proper chance to modify whatever you are asking it to. If you find that you are running into that sort of a race condition, you can slow a line (and subsequent lines) down with a delay tag which you hide with a line-deferral: !{{ &nbsp;&nbsp; !modbattr --charid @{target|character_id} --powerpoints| -5 &nbsp; (^) {&amp;template:default} ({)name=Power Points(}) ({)description= Text(}){^&amp;delay 1} }} That would use the " ^ " character to break up (or defer) the delay tag. The delay is set for 1 second, so if the script from the previous command (in this case, CSA) tried to step out of the way (asynchronously) and let execution continue to the next command, we are actually going to manually wait a full second. That gives control back to CSA and gives it time to finish. I bring this up because a lot of times I think people want to use a script (like CSA or TokenMod) to modify something which they immediately want to report on or read, but they don't give it time to finish in a multi-command line.&nbsp;
Thanks for the tip, Tim, and good point. One of my players has a.... lapse when it comes to remembering to increment his power points when used. So I want to automate the process and have it written to chat.&nbsp; I must admit I am not sure how to embed your multi-line code into a character sheet.
1693931035
timmaugh
Forum Champion
API Scripter
Fair point... Some sheets allow you to put data in a field to run a custom ability after the attack/spell/power/action completes. It would be easy enough to put this in such an ability, and have the ability automatically run. Another option would be to put the attack/spell/power/action into the ability as well -- though this isn't always possible, either. TBH, depending on your sheet, neither option may be available... but I wanted to share in case one option or the other is available.
Could your stacked code be written with a &lt;br&gt; between the elements?&nbsp; Plugging away at the desired output as time permits: to be honest I am not sure what I am looking for as a finished output. But I see now when I was fatigued last night I completely misunderstood the use of "!!!" in the code. But that is why I wrote on the forum. Thanks for the assist; it never hurts to get a second opinion or learn something new.
1693962237
timmaugh
Forum Champion
API Scripter
Unfortunately, no. If you enter those HTML tags yourself, Roll20 strips them. It's only if you are actually using line breaks in your command that you can do the batching. But if you can isolate the command line for the attack/spell/action (even if it is a template), you can put that in an ability using the ZeroFrame batch.
Found out the hard way. Tried to use the ZeroFrame based on your example and it did not work. The points stayed with the previous number after the reset put it back to max. By running a macro right after the first line though it worked. I tried a longer delay but still no good. I may return to it later but for now I have a crude but workable solution.&nbsp; This is what I tried based on your example: !{{ !resetattr --charid @{selected|character_id} --powerpoints|max!!! (^}{&amp;template:default} ({)name=Psionics(}) ({)description= @{selected|character_name} has reset Power Points to @{selected|powerpoints}!(}){^&amp;delay2} }}
1693974314
timmaugh
Forum Champion
API Scripter
A couple of things about that set of commands... ... I don't think ChatSetAttr has a "resetattr" handle; in any case, it can be handled by just "setattr" ... you don't need the !!! on the ChatSetAttr command line; since ZeroFrame batching is handling dispatching the lines and ownership of the original message, we can just leave the ChatSetAttr message as its own thing... like it isn't embedded in some other command (like a template command). ... make sure there is a space after the word "delay" in the delay tag, before the number of seconds to delay Making all of those changes, this should (theoretically) work: !{{ &nbsp; !setattr --charid @{selected|character_id} --powerpoints|max &nbsp; (^}{&amp;template:default} ({)name=Psionics(}) ({)description= @{selected|character_name} has reset Power Points to @{selected|powerpoints}!(}){^&amp;delay 2} }}
I'll give it a try tomorrow. Thanks for the feedback.&nbsp;&nbsp; As to resetattr, here is what the readme says, and it works: --reset &nbsp;will simply reset all entered attribute values to the maximum; the values you enter are ignored. You can use&nbsp; !resetattr &nbsp;as a shortcut for&nbsp; !setattr --reset . I've put the custom sheet into play, and written a changelog entry for my players so they can better use the new features. It works but is not all that pretty or elegant.&nbsp;