Hey folks, I’m trying to create a template to create a character for my TTRPG game, and some stuff of that character are based on a Random Table.
So, I created the table and start to try to roll the dice-roller
plugin to get the item I want. This works well.
But when I try to put it into the Templater
I had an issue… every time I open that character file, the result rolls again.
I tried to use the dice-mod: [[my-awesome-table]]
but it expands on the template file, not on the created file…
Anyone knows how to make it works?
<% "`dice-mod: [[my-awesome-table#^blockid]]`" %>
The above code worked perfectly for my use case, and slightly jankily for yours (if I understand yours correctly).
In my use case, I am putting the template into an existing file using the “Open Insert Template modal” hotkey.
When I created a new file from the template running the above code (which I think is your use case, right?), it initially popped up with the dice-mod
string in an inline codeblock–but as soon as I clicked into the body of the file, it replaced with the table result.
I think the reason it works is the double quotes within the Templater code string. Templater passes “text” directly into the page, so when we pass the dice-mod code string it shows up in the file, and then runs when we refresh the page.
I know this is a few months later, but I hope it helps you!
Tried to add this as an edit, but I had waited too long to edit apparently.
When I first responded it was working without any further intervention. Literally minutes later, I needed to swap between reading and editing mode to get the dice-mod code to run. I have no clue what I changed.
If you’re trying to roll a die multiple times with a template in Obsidian, one way to do this is to use a dice roller script.
You can set it up to run the roll once each time the template is used. If you need more advanced functionality, you might want to check out a solution like dice online for more features and flexibility. This could simplify your setup and give you a variety of options to work with. Let me know if you need more details on setting this up!