obsidian-dice-roller
obsidian-dice-roller copied to clipboard
Can't use flags in a table
It seems like it's not currently possible to use flags like |nodice
inside a table because Dice Roller doesn't recognize a backslash as an escape character. Is it possible to add that functionality?
@valentine195 I'll fix this if you are not already working on it. I need to refresh my regexp's 😁
Wow! Thanks for fixing this so fast! You all are awesome.
Almost perfect. Seems that if a roller with an escaped pipe is nested in another lookup table, it breaks.
For example, if I have Note2.md with:
| dice:1d% | Result |
| -------- | -------------------------------- |
| 01–50 | Nothing |
| 51–100 | `dice: [[Note1^Table1]]\|nodice` |
^Table2
And Note 3.md with:
| dice:1d% | Result |
| -------- | ------------------------ |
| 01–50 | Nothing |
| 51–100 | `dice: [[Note2^Table2]]` |
^Table3
Then the roller in Table3 will display `dice:Note2^Table2 instead of a result from Table1.
Hey @sub-atomic good catch!
I found the issue and will push a fix very soon.
I pushed a "fix"; you should now see a result, not a broken dice formula 😊
Having said that, I'm not sure what to expect exactly from nested lookup tables, so what might seem to work might still be a little bit broken / unexpected.
What I first noticed:
- Click in Note 3 => got a result from Note 1
- Click on the result (not the dice icon) => got another result from Note 1 (i.e. this seems to bypass the Note 2 entirely). You have to click on the dice icon to trigger the Note 2 roll (I was not expecting this, but I don't think this is linked to the changes for supporting flags, might be wrong though !).
To understand better, I added some logs to see the rolled values and... I've been surprised to see that clicking on the dice from Note 3 can trigger either one roll (when getting nothing from Note 2) or .... tadam... FOUR rolls (when rolling more than 50 in Note 2).
As I don't know what to expect, I stopped trying to understand deeper, at least for today. Jeremy... is this expected or does it mean that there is maybe a "hidden" bug somewhere in the lookup logic?
I just tested out your observation, @JYCasalis, and you're right. If I click the result instead of the dice in Note 3, I only get results from Table1, never Table2. I'm glad you caught that, because I've been hiding the dice since I find it visually cleaner in a large table to just have clickable results instead of all the dice. Wish I could help more in fixing it, but thanks for giving this your attention.
It’s also been brought to my attention that nested lookup table results aren’t written to the note properly when using modifier dice. This is a function of how they’re built (namely, the dice roller just renders table results, so if they’re a dice roll they’re just rendered). Right now you’re clicking an actual instance of the roller linked to table 1, not the initial dice roller used to build it, if that makes sense
For info, I've pushed yet another small fix regarding this topic.
We were replacing all escaped pipes \|
by a fixed string, doing some stuff and then reverting only the first fixed string back into an escaped pipe !
I have also tried to change the design so that TableRoller does not rely on rendering to manage nested lookup tables but does the expansion itself (i.e. so, at the end, there is only one TableRoller rendered).
That has been fun but... more challenging than I thought it would be !
I have a kind of poc that seems to work but we'll have to discuss many "details" regarding what I did and how. In particular, now that there is only one Roller rendered, there is so only one tooltip.
Anyway, I'll probably open a dedicated issue to share my poc and discuss about it (if anybody is interested of course).
@sub-atomic With version 8.5.0+, you should not face these issues anymore 😎