javalent / dice-roller

Inline dice rolling for Obsidian.md
272 stars 28 forks source link

🐞 Dex modifier breaking the Initiative tracker with Dice roller on #258

Closed f3ss1 closed 11 months ago

f3ss1 commented 12 months ago

Check for existing bug reports before submitting.

Expected Behavior

dice roller + fantasy statblocks + initiative tracker works fine for all creatures.

Current behaviour

Enabling dice roller with the fantasy statblocks and initiative tracker ruins the start combat with creatures with DEX < 10.

Reproduction

Install all the three mods, try to go to "Initiative tracker encounter builder" and add a creature like Zombie from the SRD. It won't work unless you disable the dice roller.

Which Operating Systems are you using?

Obsidian Version Check

1.4.16

Plugin Version

10.1.2

Confirmation

Possible solution

Probably the reason is the negative dex modifier to the initiative. However, simply setting the formula in initiative calculation to "4" did not work so it appears like the reason is somewhere deeper.

I found this while making custom mobs using YAML in fantasy statblock and debugged it up to this point. All the plugins are up to date to the current date.

f3ss1 commented 12 months ago

UPD: it appears that I made a mistake while debugging and removing %mod% from the initiative formula indeed fixes the thing so I would look into the modifier.

twiescha commented 12 months ago

Just had a look in the debugger. The problem are negative modifiers. The diceroller needs to parse en expression like "1d20 + -2" in that case, which will result in the exact same error in calculate() when used in isolation as a formula in the dice tray. I think it basically treats it as ["1d20", "+", "-", "2"] instead of ["1d20", "+", "-2"], so the solution might be in the lexer that maybe currently misinterprets the unary '-' sign.

Once such a formula is entered i cannot make any more rolls via the dicetray until obsidian is restarted. Can anyone confirm?

Version is 10.1.2 here.

f3ss1 commented 12 months ago

@twiescha I bumped into something like this yesterday (the dicetray did not allow to make rolls, the button was unclickable) after doing something like 1d20 + 4 guess (but I am not sure on this one tbh so cannot reproduce).