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 .
×

ChatSetAttr: Need help regarding waiting for second command / templates as values

Hello, is there any way for 2 commands to be executed in the same chat message, but command 2 will wait for the command 1 to be finished? I'm currently trying to make monster importer for 3.5 via c# that takes statblock and generates ChatSetAttr command to set up the fields of a card. My current problem is that I cannot pass &{template:DnD35Attack} as value of the field i want to update because it probably executes, so my solution to that is to first pass {template:DnD35Attack} and then use ChatSetAttr to add & as first char of the field, but those are 2 separate commands which if posted in one chat message executes together and do not work.
1786461340

Edited 1786461400
Gauss
Forum Champion
Hi Art J.,  If you use HTML substitution you can do it all in one pass.  Instead of &{template:DnD35Attack} try:  &{template:DnD35Attack}
I'm not sure that the problem is that the &{template} value is executing. I think you likely simply need to use the --replace functionality in ChatSetAttr. It would be helpful if you posted your entire workflow (an example of each step, not the entire thing) and what your expected outcome is and what is occurring instead.  E.g. What field are you trying to update with the &{template} value? What ChatSetAttr command are you using to try to update that field? 
I'm already using replace, I might be using it wrongly. Smallest example would be: !setattr --sel --replace --weapon4fullattackmacro|&{template:DnD35Attack}, The output i'm getting is:  Setting attributes Setting weapon4fullattackmacro to (empty) for character Glabrezu. If i do --weapon4fullattackmacro|{template:DnD35Attack} {{{{pcflag=true}}  i only get {{pcflag=true}} in that field.
1786469049
Gauss
Forum Champion
Shouldn't need replace for this. I tested with HTML substitution and it worked correctly. 
1786474307

Edited 1786475141
Oh, sorry, this is because it's not full, i'm using replace for later things like @ and [[ ]] --weapon4fullattackmacro|{template:DnD35Attack} {{{{pcflag=true}} {{name=`{character_name}}} {{subtags=2 pincers + 2 claws + bite}} {{attack1=pincers: << `{weapon1attackcalc} >> }}  Also I've tried using standalone !setattr --sel --weapon4fullattackmacro|&{template:DnD35Attack}  I'm literally getting &{template:DnD35Attack} When clicking on the dice on the card im getting correct value but not the execution of the template, the line is &{template:DnD35Attack}a in the field while under the line we have this in the field: &{template:DnD35Attack}
I still have a feeling there's more going on here, but you're only giving me a portion of the whole thing you're trying to do.  If you only replace the ' weapon4fullattackmacro' attribute with ' &{template:DnD35Attack}', then call the attribute, nothing will happen, because it's just the roll template.  There are likely one of two things happening: part of the message is getting parsed by Roll20 before ChatSetAttr can process it; or (more likely) the sheetworkers on the DnD3.5 sheet are rewriting the field. The sheetworkers are fairly aggressive on that sheet, which is apparent if you create the ' weapon4fullattackmacro' attribute manually, then delete it, the sheetworkers will immediately recreate it. Gauss' example of using html replacements only works if you don't include the --replace function, because --replace changes all ; to @.  In any case, if html replacements aren't working for you, then you can use the ChatSetAttr --replace functionality if you modify the script code , because it doesn't have a replacement for & or } natively built in. Or if you don't want to modify the ChatSetAttr code, then you can use Metascripts as a replacer function . The html replacement I tried out and appears to work is:   [/\\amp/g, "&"], Then I ran this: !setattr --sel --replace --weapon4fullattackmacro|\amp{template:DnD35Attack} {{{{pcflag=true}} {{name=`{character_name}}} {{subtags=2 pincers + 2 claws + bite}} {{attack1=pincers: << `{weapon1attackcalc} >> }} Then running @{Glabrezu|weapon4fullattackmacro} gets this output: But honestly I'm not sure where the ' weapon4fullattackmacro' lives on the sheet, because it's not visible on the Attributes & Abilities tab, and I don't see a field anywhere on the sheet that shows that change. 
Thanks for the help :) I've added this replacement:  ['/amp', '&', /\/amp/g, /&/g]], and it's working now. This weapon4fullattackmacro lives on the sheet in weapons, but you need to select attack and damage single roll on top
1786480477
Gauss
Forum Champion
Art J. said: Oh, sorry, this is because it's not full, i'm using replace for later things like @ and [[ ]] --weapon4fullattackmacro|{template:DnD35Attack} {{{{pcflag=true}} {{name=`{character_name}}} {{subtags=2 pincers + 2 claws + bite}} {{attack1=pincers: << `{weapon1attackcalc} >> }}  Also I've tried using standalone !setattr --sel --weapon4fullattackmacro|&{template:DnD35Attack}  I'm literally getting &{template:DnD35Attack} When clicking on the dice on the card im getting correct value but not the execution of the template, the line is &{template:DnD35Attack}a in the field while under the line we have this in the field: &{template:DnD35Attack} Odd, it is resolving correctly for me. I'd have to see your setup in more detail. 
About HTML substitution - I'm using Diana P. 3.5 character sheet and in terms of any other scripts here they are: as for the effect ChatSetAttr seems to be correct in knowing what i want but it saves  the original value
1786494727
Gauss
Forum Champion
Art, would you mind jumping into a Discord call with me? I'd like to discuss more of what you are experiencing, and via screensharing you can show me the trouble you are running into. It might go faster.  You can find me near the top of the Roll20 Discord server in the "Champion of Roll20" category.
Yea, I'm cool with it, albeit at the time of your post it was 2 AM for me and i was sleeping, I'm from europe and in CEST time zone
1786564994

Edited 1786565143
Gauss
Forum Champion
For anyone following:&nbsp; There are basically two methods to do this.&nbsp; Method 1: Use HTML entities:&nbsp; <a href="https://wiki.roll20.net/HTML_Entities" rel="nofollow">https://wiki.roll20.net/HTML_Entities</a> Method 2: Use replacements (--replace option) provided by ChatSetAttr.&nbsp; <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> Sometimes I find method 2 to be easier, but usually I find it to be a bit harder so I typically use HTML entities.&nbsp; Note: on the HTML entities # doesn't play nice with ChatSetAttr, so use the word version instead of the number version.&nbsp; Example: &amp;#124; is also &amp;vert; The # will cause ChatSetAttr to split the input into the attribute across both the current and max boxes like this:&nbsp; current: &amp; max: 124; This is because in CSA # (and the pipe or vert: "|" ) mean "go to the max box".&nbsp; So we use &amp;vert; instead of &amp;#124; However, in the scenario where you need &amp;#124; to be sent cleanly to the attribute, such as in the instance of a nested query, then you may want to use &amp;#124; but use "\" to prevent # from being resolved.&nbsp; &amp;\#124; will be sent to the attribute as: &amp;#124; instead of "|" (without quotes).&nbsp; So it depends on the output you want from CSA into the attribute.&nbsp; The 3 main entities that Art needs above are:&nbsp; "}" = &amp;rbrace; or for nested queries: &amp;\#125; (already put the \ in) "]" = &amp;rbrack; "|" = &amp;vert; or for nested queries: &amp;\#124; An example of nesting a query where the outer query goes into the attribute cleanly, but the inner query retains html entities might look like this (air coded, not verified): How it looks without html entities: ?{Outer query|1,1d2[output1]|?{Inner query|0}[output2]} How it looks if just in a macro: ?{Outer query|1,1d2[output1]|?{Inner query&amp;#124;0&amp;#125;[output2]} How it looks if using CSA to inject it into an attribute: ?{Outer query&amp;vert;1,1d2[output1&amp;rbrack;&amp;vert;?{Inner query&amp;\#124;0&amp;\#125;[output2&amp;rbrack;&amp;rbrace;