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

Inconsistant output with Roll Templates and SheetWorkers

1512814773

Edited 1512815061
Toby
Pro
I have run into an issue roll template hiding the roll for some rolls and expanding other rolls. I am using a sheet worker script to set up attack rolls because I want to eventually create multi attack scripts.  I am not showing the whole code because its not relevant. The sheet worker code is: var critHit = parseInt(v[prefix+"_crit-target"])||0, critFail = parseInt(v[prefix+"_fail-target"])||0; var rDMod = parseFloat(v["DMG_ranged-mod"],10) || 0, rDMod2 = parseFloat(v["DMG_ranged2-mod"],10) || 0; var mDMod = parseFloat(v["DMG-mod"],10) || 0, mDMod2 = parseFloat(v["DMG2-mod"],10) || 0 if (atkType === "0") {attackType="None", buff_DMG_mod=0;} else if (atkType === "attk-melee") {atkRoll="[[ 1d20cf<"+critFail+"cs>"+critHit+" + @{attk-melee} ]]", attackType="Melee", buff_DMG_mod=mDMod;} else if (atkType === "attk-melee2") {atkRoll="[[ 1d20cf<"+critFail+"cs>"+critHit+" + @{attk-melee2} ]]", attackType="Melee2", buff_DMG_mod=mDMod2;} else if (atkType === "attk-ranged") {atkRoll="[[ 1d20cf<"+critFail+"cs>"+critHit+" + @{attk-ranged} ]]", attackType="Ranged", buff_DMG_mod=rDMod;} else if (atkType === "attk-ranged2") {atkRoll="[[ 1d20cf<"+critFail+"cs>"+critHit+" + @{attk-ranged2} ]]", attackType="Ranged2", buff_DMG_mod=rDMod2;} else if (atkType === "CMB") {atkRoll="[[ 1d20cf<"+critFail+"cs>"+critHit+" + @{attk-CMB} ]]", attackType="CMB";} else if (atkType === "CMB2") {atkRoll="[[ 1d20cf<"+critFail+"cs>"+critHit+" + @{attk-CMB2} ]]", attackType="CMB2";} console.log("ABILITY: Attack Type: " +attackType+ " || Attack Roll " +atkRoll+ " Bonus Damage: " +buff_DMG_mod+ "."); the atkRoll variable sets an attribute @{attackRoll}  When I use that in a roll template sometimes the roll is displayed as text other times its an expanded roll.  I wouldn't care except if it is just text then there is no point to having any of the FAIL/CRIT.  Because, obviously there is no color distinction. The roll template code is: &{template:35Adv_spell} @{abilOptions} {{name=@{name}}} {{ability_type=@{ability_type}}} {{frequency=@{useDisplay}}} {{school=@{cust-category}}} {{level=@{class-name} @{spell_level}}} {{metamagic=NONE}} {{casting_time=NONE}} {{range=@{rangeDisplay}}} {{target=@{targets}}} {{duration=@{duration}}} {{sr=[[1d20+@{casterlevel}]]}} {{vsSR=@{abil-sr}}} {{saving_throw1=@{save} [[@{savedc}]]}} {{saving_throw2=@{save2} [[@{savedc}]]}} {{extra_details=@{short-description} }} {{spell_description=@{description}}} {{spell_chk=[[{1d100}>@{spell-fail}]] }} {{succeedcheck=You are able to cast!}} {{failcheck= You Fail casting spell!}} {{spl_damage=**Damage:** @{damage-macro-text}}} {{spl_attack=@{attackRoll} / @{attackRoll} / @{attackRoll} / @{attackRoll} }} {{Concentration=[[ [[1d20]]+[[@{Concentration-Mod}]] ]]}} {{conc_def=+[[@{Concentration-0-defensive}]]}} and this is what it looks like: What is causing this problem, and how can I resolve it.
1512850278
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
We need to seethe actual html code for the roll template, not the macro code.
Here is the html code for the roll template: <rolltemplate class="sheet-rolltemplate-35Adv_spell"><!-- Advanced Spell Roll Template -->     <div class="sheet-wrapper"> <div class="sheet-border"> <table> <tr><th>{{name}} {{#ability_type}}{{ability_type}}{{/ability_type}}</th>{{#infolink}}<th class="sheet-info">[i]({{infolink}})</th>{{/infolink}}</tr> {{#rollTotal() show-frequency 1}}<tr><td><span>{{frequency}}</span></td></tr>{{/rollTotal() show-frequency 1}} <!-- {{#spl_attack}}{{#show-attack1}} <tr><td><span class="tcat">on </span>{{spell_target}}</td></tr> <tr class="arrow-container"><td><div class="arrow-left"></div></td></tr> {{/show-attack1}}{{/spl_attack}} --> {{#school}}{{#rollTotal() show-school 1}}<tr><td><span class="tcat">School </span>{{school}} {{subschool}}</tr></td>{{/rollTotal() show-school 1}}{{/school}} {{#class}}<tr><td><span class="tcat">Class </span>{{class}}</tr></td>{{/class}}<!-- Used for Class Abilities --> {{#rollTotal() show-level 1}}<tr><td>{{#level}}<span class="tcat">Level </span>{{level}}{{/level}} {{#rollTotal() show-metamagic 1}} {{metamagic}} {{/rollTotal() show-metamagic 1}}</td></tr>{{/rollTotal() show-level 1}} {{#psi_discipline}}<tr><td><span class="tcat">Disc </span>{{psi_discipline}}; <span class="tcat">Level </span>{{level}}</td></tr>{{/psi_discipline}} {{#invoke_grade}}<tr><td><span class="tcat">Grade </span>{{invoke_grade}};level: {{invocation_level}}</td></tr>{{/invoke_grade}} {{#display}}<tr><td><span class="tcat">Display: </span>{{display}}{{/display}}</tr><td> {{#psi_pri-display}}<tr><td><span class="tcat">Display Pri: </span>{{psi_pri-display}}{{#psi_sec-display}}; <span class="tcat">Sec: </span>{{psi_sec-display}}{{/psi_sec-display}}</td></tr>{{/psi_pri-display}} {{#rollTotal() show-spellfail 1}} <tr><td><span class="tcat">Spell Fail </span>  {{spell_chk}} {{#rollTotal() spell_chk 1}} <span class="hroll">{{succeedcheck}}</span> {{/rollTotal() spell_chk 1}} {{#rollTotal() spell_chk 0}} <span class="hroll">{{failcheck}}</span> {{/rollTotal() spell_chk 0}} </td></tr> {{/rollTotal() show-spellfail 1}} {{#rollTotal() show-umdcheck 1}}<tr><td><span class="tcat">Use Magic Device </span>{{use_magic_device}} vs varies</td></tr>{{/rollTotal() show-umdcheck 1}}  {{#casting_time}}{{#rollTotal() show-castingtime 1}}<tr><td><span class="tcat">Casting Time </span>{{casting_time}}</td></tr>{{/rollTotal() show-castingtime 1}}{{/casting_time}} {{#components}}{{#rollTotal() show-components 1}}<tr><td><span class="tcat">Components </span>{{components}}</td></tr>{{/rollTotal() show-components 1}}{{/components}} {{#range}}{{#rollTotal() show-range 1}}<tr><td><span class="tcat">Range </span>{{range}}</td></tr>{{/rollTotal() show-range 1}}{{/range}} {{#target}}{{#rollTotal() show-target 1}}<tr><td><span class="tcat">Target </span>{{target}}</td></tr>{{/rollTotal() show-target 1}}{{/target}} {{#duration}}{{#rollTotal() show-duration 1}}<tr><td><span class="tcat">Duration </span>{{duration}}</td></tr>{{/rollTotal() show-duration 1}}{{/duration}} {{#rollTotal() show-sr 1}}<tr><td><span class="tcat">Spell Resist </span>{{sr}} vs {{vsSR}}</td></tr>{{/rollTotal() show-sr 1}} {{#rollTotal() show-pr 1}}<tr><td><span class="tcat">Power Resist </span>{{pr}} vs {{vsPR}}</td></tr>{{/rollTotal() show-pr 1}}<!--Power Resist: Used for psionic abilities only --> {{#rollTotal() show-concentration 1}}<tr><td><span class="tcat">Concentration </span>{{Concentration}}</td></tr> {{#conc_def}}<tr><td><span class="tcat sheet-indent">Cast Defensively </span>{{conc_def}}</td></tr>{{/conc_def}} {{/rollTotal() show-concentration 1}} {{#rollTotal() show-save1 1}} {{#saving_throw1}}<tr><td><span class="tcat">Save </span>{{saving_throw1}} {{save1type}}</td></tr>{{/saving_throw1}} {{#save_fail1}}<tr><td><span class="tcat sheet-indent">on Fail </span>{{save_fail1}}</td></tr>{{/save_fail1}} {{#save_success1}}<tr><td><span class="tcat sheet-indent">on Success </span>{{save_success1}}</td></tr>{{/save_success1}} {{/rollTotal() show-save1 1}} {{#rollTotal() show-save2 1}} <tr><td><span class="tcat">2nd Save </span>{{saving_throw2}}{{save2type}}</td></tr> {{#save_fail2}}<tr><td><span class="tcat sheet-indent">on Fail </span>{{save_fail2}}</td></tr>{{/save_fail2}} {{#save_success2}}<tr><td><span class="tcat sheet-indent">on Success </span>{{save_success2}}</td></tr>{{/save_success2}} {{/rollTotal() show-save2 1}} {{#rollTotal() show-attack1 1}}<!--      ^ -- This "tcat></span> point includes an indication of what kind of attack it is." --> <tr><td><span class="tcat"> </span>{{spl_attack}}{{#show-attack2}} /{{spl_attack2}}{{#show-attack3}} /{{spl_attack3}}{{#show-attack4}} /{{spl_attack4}}{{#show-attack5}} /{{spl_attack5}} {{/show-attack5}}{{/show-attack4}}{{/show-attack3}}{{/show-attack2}}<!--  vs  -->{{atk_target}}</td></tr>{{/rollTotal() show-attack1 1}} <!-- #dam_display and #damage must both have a value in order for this section to show --> {{#rollTotal() show-damage1 1}}<!--      ^ -- This "tcat></span> point includes an indication of what kind of damage it is." --> <tr><td><span class="tcat"> </span>{{spl_damage}}{{#show-damage2}} /{{spl_damage2}}{{#show-damage3}} /{{spl_damage3}}{{#show-damage4}} /{{spl_damage4}}{{#show-damage5}} /{{spl_damage5}} {{/show-damage5}}{{/show-damage4}}{{/show-damage3}}{{/show-damage2}}</td></tr>{{/rollTotal() show-damage1 1}} {{#rollTotal() show-spelldescription 1}} <!-- <tr><td><span class="sheet-sm_text">{{spell_atkdam}}</span></td></tr> --> {{#extra_details}}<tr><td><span class="tcat"></span>{{extra_details}}</td></tr>{{/extra_details}} {{#spell_description}}<tr><td><span class="sheet-sm_text">{{spell_description}}</span></td></tr>{{/spell_description}} {{/rollTotal() show-spelldescription 1}} {{#rollTotal() spell_components 1}}<tr><td><span class="tcat">Cost to Cast </span>{{spell_components}}</td></tr>{{/rollTotal() spell_components 1}} {{#rollTotal() show-psiaugments 1}} {{#psi_augment1}}<tr><td><span class="tcat sheet-indent">Aug (Svs) </span>{{psi_augment1}}</td></tr>{{/psi_augment1}} {{#psi_augment2}}<tr><td><span class="tcat sheet-indent">Aug (Dam) </span>{{psi_augment2}}</td></tr>{{/psi_augment2}} {{#psi_augment3}}<tr><td><span class="tcat sheet-indent">Aug 3 </span>{{psi_augment3}}</td></tr>{{/psi_augment3}} {{#psi_augment4}}<tr><td><span class="tcat sheet-indent">Aug 4 </span>{{psi_augment4}}</td></tr>{{/psi_augment4}} {{/rollTotal() show-psiaugments 1}} <tr><td><span style="display: none;">{{show-school}}{{show-attack1}}{{show-damage1}}</span></td></tr> </table> </div>{{show-psiaugments=[[1d1]]}}     </div> </rolltemplate>
Did I not give the information you were looking for?
1512953278
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
No, you did, just been away from my comp for most of the weekend. Throw this snippet into your API scripts: on('chat:message',(msg)=>{ log(msg.content); });
1512958957

Edited 1512958977
Toby
Pro
Scott C. said: No, you did, just been away from my comp for most of the weekend. Throw this snippet into your API scripts: on('chat:message',(msg)=>{ log(msg.content); }); Where?  I've posted that exactly as typed right after the section that has my ABILITY code and it has no effect, I tried posting that right under the code snippet and it had no effect?  What was it supposed to do exactly?
1512959319

Edited 1512959391
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Throw this snippet into your API scripts : It'll log what the macro is sending to chat to see what is going on.
Okay here is what I get:   {{spl_attack=27}} This uses: {{spl_attack=@{attackRoll} }} in the macro code " {{show-school=$[[0]]}} {{show-frequency={{show-frequency=$[[1]]}}}} {{show-concentration=$[[2]]}} {{show-level=$[[3]]}} {{show-castingtime=$[[4]]}} {{show-range=$[[5]]}} {{show-target=$[[6]]}} {{show-duration=$[[7]]}} {{show-save1=$[[8]]}} {{show-save2={{show-save2=$[[9]]}}}} {{show-sr={{show-sr=$[[10]]}}}} {{show-spelldescription=$[[11]]}} {{show-spellfail=$[[12]]}} {{show-attack1={{show-attack1=$[[13]]}}}} {{show-damage1=$[[14]]}} {{name=Test Ability}} {{ability_type=Sp}} {{frequency=2/2/month}} {{school=}} {{level=Druid 4}} {{metamagic=NONE}} {{casting_time=NONE}} {{range=Touch}} {{target=}} {{duration=}} {{sr=$[[15]]}} {{vsSR=No}} {{saving_throw1= $[[16]]}} {{saving_throw2= $[[17]]}} {{extra_details=short desc }} {{spell_description=$[[18]]+16}} {{spell_chk=$[[19]] }} {{succeedcheck=You are able to cast!}} {{failcheck= You Fail casting spell!}} {{spl_damage=**Damage:** $[[24]]}} {{spl_attack=27}} {{Concentration=27}} {{conc_def=+$[[25]]}}" If I have this in the macro code: {{spl_attack=@{attackRoll}@{attackRoll}@{attackRoll} }} I get this:  {{spl_attack=1633$[[25]] }} " {{show-school=$[[0]]}} {{show-frequency={{show-frequency=$[[1]]}}}} {{show-concentration=$[[2]]}} {{show-level=$[[3]]}} {{show-castingtime=$[[4]]}} {{show-range=$[[5]]}} {{show-target=$[[6]]}} {{show-duration=$[[7]]}} {{show-save1=$[[8]]}} {{show-save2={{show-save2=$[[9]]}}}} {{show-sr={{show-sr=$[[10]]}}}} {{show-spelldescription=$[[11]]}} {{show-spellfail=$[[12]]}} {{show-attack1={{show-attack1=$[[13]]}}}} {{show-damage1=$[[14]]}} {{name=Test Ability}} {{ability_type=Sp}} {{frequency=2/2/month}} {{school=}} {{level=Druid 4}} {{metamagic=NONE}} {{casting_time=NONE}} {{range=Touch}} {{target=}} {{duration=}} {{sr=$[[15]]}} {{vsSR=No}} {{saving_throw1= $[[16]]}} {{saving_throw2= $[[17]]}} {{extra_details=short desc }} {{spell_description=$[[18]]+16}} {{spell_chk=$[[19]] }} {{succeedcheck=You are able to cast!}} {{failcheck= You Fail casting spell!}} {{spl_damage=**Damage:** $[[24]]}} {{spl_attack=1633$[[25]] }} {{Concentration=$[[26]]}} {{conc_def=+$[[27]]}}" So, you can see that duplicating the rolls three times produces two consecutive incorrect displays and the final one displays on screen with all of the colors and whatever nonsense that shows the code, as desired.
1512961405
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, I'd try seeing what happens if you manually do the macro you are doing, minus the roll template stuff. The issue isn't your roll template. It's something about how you've got the attack macro set up.
I've already tested that.  It works just fine when I put the roll @{attackRoll} inside of the Description field of the attack.
1512962083
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, I've got no clue then.
1513014971
chris b.
Pro
Sheet Author
API Scripter
If you get different things when putting @{attackroll} one after the other then there might be either mismatched brackets, or maybe in the attackroll you end up with a  "}}" somewhere which looks ok when you send it straight to chat, but inside a rolltemplate might cut off the section too early.
I'm not really sure how to determine this beyond trial and error that I have already used.