javalent / fantasy-statblocks

Create Dungeons and Dragons style statblocks for Obsidian.md
MIT License
346 stars 72 forks source link

🐞 Dice Callback (probably) not working #303

Closed silentjames closed 10 months ago

silentjames commented 10 months ago

Check for existing bug reports before submitting.

Expected Behavior

If Dice Callback is provided, it should be visible and clickable.

Current behaviour

Well, his time it might be not a bug, because I barely know JS, but you don't know unless you ask! :) For me, it looks like Dice Callback block stopped working with 3.15.7. I've had a simple code for dice callback: return [{ text: monster.Strength, 'd10|none|noform|nodice|text(', monster.Strength,')' }] that returned me something like 4d10|none|noform|nodice|text(4). With 3.15.7 (and 3.15.8), it stopped working. I tried to modify this "code" with my zero knowledge, without any success. After all, I copied and pasted the provided example:

const diceText1 = monster.Strength + "d20 +2";
return ["blah blah: ", { text: diceText1 }, " blah."];

but even this code did nothing. But! I copied the same lines into simple Callback block - and got the result! Yes, it just returns (blah blah: 4d20 +2 blah.), no dice options ofc, but it's still something!

I still don't know is it a bug or I just cannot understand how JS works. In the latter case I'd appreciate any advice.

Reproduction

  1. Create property block;
  2. Link monster property as "Strength";
  3. Enable "Parse for Dice" toggle;
  4. Paste this in the Dice Callback block:
    const diceText1 = monster.Strength + "d20 +2";
    return ["blah blah: ", { text: diceText1 }, " blah."];
  5. Save all changes;
  6. Add statblock to a note and type Strength: 4 inside;
  7. Switch to reading mode -> you'll see Strength: 4, but it should be something like blah blah: 18 blah.

Which Operating Systems are you using?

Obsidian Version Check

1.4.16 and 1.4.13

Plugin Version

3.15.8

Confirmation

Possible solution

No response

valentine195 commented 10 months ago

Actually this might have been a breaking change that I will need to fix.

Previously, using a dice callback required having Parse for Dice turned on, but it was not intuitive. I removed that restriction, but I believe turning that on might now prevent dice callbacks.

Try turning it off in your layout. I will push a fix in a few hours.

silentjames commented 10 months ago

Ha-ha-ha, you're right! With this toggle off, even my old code works now :)

valentine195 commented 10 months ago

fixed in 3.15.9