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

[Splittermond] Custom Roll Parsing: Computed value isn't updated


Edited 1632138277
Sheet Author
Hey, once again I have a problem with the Custom Roll Parsing. A specific attribute that I send in the roll string doesn't get updated with the computed value no matter what I do. 1. I construct the roll string based on the dice mode: switch (+values.dice_mod) { case 1: baseDice = "[[{[[1d10]],[[1d10]]}k1]]"; baseRoll = `@{abilityroll} {{name=${rollName}}} {{charactername=@{character_name}}} {{Probe=[[ ${baseDice} + [[${sum}]] ]]}} {{mod=[[?{Situationsmodifikator|0}]]}} {{erfolge=[[1]]}} {{wuerfel1=$[[0]]}} {{wuerfel2=$[[1]]}} {{sicherheitswurf=$[[2]]}} {{mode=[[1]]}} {{success=[[0]]}} {{dmgmalus=[[@{schadensmod}d1]]}} {{geblendet=[[@{geblendet}d1]]}} {{basiswert=[[${vStat}d1]]}} {{skillbonus=[[${bStat}]]}} {{attributsmodifikatoren=[[${attributsmodssum}]]}} {{erschoepft=[[@{erschoepft}d1]]}} {{bbeh=[[${bBeh}]]}} {{behinderung=[[${behinderung}]]}} {{grossmeister=[[1d10]]}} {{schwierigkeit=[[1d0 + ?{Schwierigkeit|15}]]}}`; break; case 3: baseDice = "[[{[[1d10]],[[1d10]],[[1d10]],[[1d10]]}k2]]"; baseRoll = `@{abilityroll} {{name=${rollName}}} {{charactername=@{character_name}}} {{Probe=[[ ${baseDice} + [[${sum}]] ]]}} {{mod=[[?{Situationsmodifikator|0}]]}} {{erfolge=[[1]]}} {{wuerfel1=$[[0]]}} {{wuerfel2=$[[1]]}} {{wuerfel3=$[[2]]}} {{wuerfel4=$[[3]]}} {{risikowurf=$[[4]]}} {{mode=[[4]]}} {{success=[[0]]}} {{dmgmalus=[[@{schadensmod}d1]]}} {{geblendet=[[@{geblendet}d1]]}} {{basiswert=[[${vStat}d1]]}} {{skillbonus=[[${bStat}]]}} {{attributsmodifikatoren=[[${attributsmodssum}]]}} {{erschoepft=[[@{erschoepft}d1]]}} {{bbeh=[[${bBeh}]]}} {{behinderung=[[${behinderung}]]}} {{grossmeister=[[1d10]]}} {{schwierigkeit=[[1d0 + ?{Schwierigkeit|15}]]}}`; break; default: baseDice = "[[[[1d10]] + [[1d10]]]]"; baseRoll = `@{abilityroll} {{name=${rollName}}} {{charactername=@{character_name}}} {{Probe=[[ ${baseDice} + [[${sum}]] ]]}} {{mod=[[?{Situationsmodifikator|0}]]}} {{erfolge=[[1]]}} {{wuerfel1=$[[0]]}} {{wuerfel2=$[[1]]}} {{standardwurf=$[[2]]}} {{mode=[[2]]}} {{success=[[0]]}} {{dmgmalus=[[@{schadensmod}d1]]}} {{geblendet=[[@{geblendet}d1]]}} {{basiswert=[[${vStat}d1]]}} {{skillbonus=[[${bStat}]]}} {{attributsmodifikatoren=[[${attributsmodssum}]]}} {{erschoepft=[[@{erschoepft}d1]]}} {{bbeh=[[${bBeh}]]}} {{behinderung=[[${behinderung}]]}} {{grossmeister=[[1d10]]}} {{schwierigkeit=[[1d0 + ?{Schwierigkeit|15}]]}}`; break; } The attribute in question is marked bold. 2. The roll is processed: function processRoll(baseRoll) { startRoll(baseRoll, (results) => { let dice = []; let mEg = 0; let diff = 0; let eg = 0; let result = results.results.Probe.result; let success = results.results.success.result; let schwierigkeit = results.results.schwierigkeit.result; let mod = +results.results.mod.result; let mode = +results.results.mode.result; let grossmeister = +results.results.grossmeister.result; console.log("Großmeister: " + grossmeister); dice.push(+results.results.wuerfel1.result); dice.push(+results.results.wuerfel2.result); if (+mode == 4) { dice.push(+results.results.wuerfel3.result); dice.push(+results.results.wuerfel4.result); } success = checkForFumbleAndCriticalSuccess(dice, mode); result += +mod; if (+success == 1) { mEg -= 3; if (mode == 4) { let sDice = dice.sort(function(a, b) { return a - b; }); result -= (+sDice[2] + +sDice[3]); result += (+sDice[0] + +sDice[1]); } } else if (+success == 2) { if (isSuccess(result, schwierigkeit)) { mEg += 3; } } diff = result - schwierigkeit; if (isSuccess(result, schwierigkeit)) { eg = Math.floor( +diff / 3 ) + +mEg; } else { eg = Math.ceil( +diff / 3) + +mEg; } finishRoll( results.rollId, { erfolge: eg, success: success, Probe: result, grossmeister: 4 } ); }); } Note: The console.log shows the correct value, so grossmeister has the value of a rolled d10. But the line grossmeister: 4 Doesn't get executed (grossmeister: grossmeister also doesn't get executed). As you can see in the chat result: It prints out grossmeister correctly, but not the calculated (grossmeister_c) - it's just blank. The roll template is quite long but the output is right at the beginning: <rolltemplate class="sheet-rolltemplate-splittermond_generic"> grossmeister: {{grossmeister}} <br> grossmeister_c: {{computed::grossmeister}} <br> <div class="roll-message"> ... </rolltemplate> I double- and triple-checked the spelling, but it should be consistent. What's extra weird is that if I apply the value of the variable grossmeister to another attribute (e.g. Probe ) it is shown correctly. finishRoll( results.rollId, { erfolge: eg, success: success, Probe: grossmeister } ); This just works fine ({{computed::Probe}} shows the value of grossmeister but {{computed:grossmeister}} won't show neither 4 nor grossmeister ). No matter what I do - changing the order of the attributes in the finishRoll()-function or changing the attribute's name from grossmeister to gmr (in the roll string construction and in the finishRoll and roll template) or whatever - it doesn't work. I feel like I'm just overseeing something very simple, but I'm looking at this problem for hours now and couldn't find the error. Can someone help me out? Cheers!
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Currently there is a bug with roll parsing where you can only display computed values for the first 10 fields in the chat message. You'll need to rearrange your fields so all your computer fields are in the first 10.
Sheet Author
Wow. That was helpful, thank you Scott! I would never have thought of that. óò Cheers!