Obsidian - Creating TTRPG Calculators with DataviewJS and ChatGPT
Based on Josh Plunkett's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Enable DataView’s JavaScript features by turning on both “Enable JavaScript queries” and “Enable inline JavaScript queries.”
Briefing
Tabletop RPG players can turn Obsidian into a quick-calculation workstation by embedding small “apps” inside notes using the DataViewJS plugin. The core idea is to build interactive calculators—like Pathfinder 2e jump distance, difficulty class (DC) thresholds, and even travel-time estimates—so players can enter a few numbers and get results instantly during play.
The walkthrough starts with a working jump distance calculator inside an Obsidian note. After installing DataView and enabling both “JavaScript queries” and “inline JavaScript queries” in DataView settings, the calculator appears as a button-driven interface. Enter a Strength value, press “calculate,” and the note outputs different jump distances for running long jump, standing long jump, and vertical jump variants. The calculator is designed to be reusable: the same note can be dragged into sidebars or kept alongside other tools, effectively acting like a plug-in panel inside the vault.
From there, the focus shifts to how these calculators are actually built. The jump calculator’s code defines input fields (for example, Strength), renders output text on the page, and uses a click event listener to compute results. It also includes a small housekeeping step—clearing prior output—so repeated button presses don’t keep appending duplicate results. The presenter emphasizes that the JavaScript involved is readable enough for non-experts to adapt, even if they can’t write it from scratch.
That’s where ChatGPT enters as a practical workaround for people who can’t code. Instead of manually writing DataViewJS from the ground up, the process is to copy a known working calculator’s code as a template, then ask ChatGPT to generate a new DataViewJS application for a specific RPG mechanic. A DC calculator example shows the workflow: paste ChatGPT-generated code into a new Obsidian note using the correct DataViewJS code block tags, then test it with sample inputs. When errors appear—such as issues with DV dot fragment—ChatGPT can be prompted with the exact error message to produce an updated version (for example, switching to db.div to create the needed container).
The transcript also highlights that results aren’t always perfect on the first attempt. Iteration matters: sometimes ChatGPT overwrites the wrong section, produces a non-working fragment, or requires more precise instructions (like explicitly setting a default level). Still, the overall payoff is significant: after roughly an hour and a half of back-and-forth, a more complex Pathfinder 2e travel calculator becomes functional. In that case, ChatGPT initially tried to use a lookup-table approach, but Obsidian/DataViewJS struggled with the needed query logic; switching to nested if-then conditionals made the calculator work.
The takeaway is less about any single calculator and more about a repeatable method: enable DataViewJS, start from a working template, use ChatGPT to generate or modify code for specific TTRPG rules, and verify calculations before trusting them at the table.
Cornell Notes
Obsidian can host interactive TTRPG calculators by using the DataViewJS plugin to render input fields, buttons, and computed results inside notes. After enabling “JavaScript queries” and “inline JavaScript queries,” a jump-distance calculator can be tested by entering Strength and clicking a calculate button to produce running/standing/vertical jump distances. For mechanics that require more logic—like Pathfinder 2e DCs and travel time—ChatGPT can generate DataViewJS code when given a working template and clear rule targets. The process often needs iteration, including fixing DataViewJS-specific errors (e.g., replacing DV dot fragment with db.div) and double-checking the math before using it in real sessions.
What setup steps make DataViewJS calculators work inside Obsidian notes?
How does the jump-distance calculator behave when used during play?
Why does starting from a known working calculator matter when using ChatGPT?
What happens when ChatGPT-generated DataViewJS code fails, and how is it fixed?
How was the Pathfinder 2e travel calculator made to work despite initial complexity?
What practical guidance is given for trusting calculator outputs?
Review Questions
- What DataView settings must be enabled to run interactive JavaScript inside Obsidian notes?
- Describe the iterative workflow for generating a new DataViewJS calculator with ChatGPT when errors occur.
- Why might a lookup-table strategy fail in DataViewJS, and what alternative logic approach can work instead?
Key Points
- 1
Enable DataView’s JavaScript features by turning on both “Enable JavaScript queries” and “Enable inline JavaScript queries.”
- 2
Build calculators as note-embedded mini-apps: input fields collect values, a button triggers computation, and output text is rendered on the page.
- 3
Use a known working DataViewJS calculator as a template so ChatGPT can generate correct Obsidian/DataViewJS structure rather than starting from scratch.
- 4
When code fails, copy the exact error message and prompt ChatGPT to revise the implementation (for example, switching from DV dot fragment to db.div).
- 5
Expect iteration: ChatGPT may overwrite the wrong defaults or produce non-working code unless prompts are specific and testing is repeated.
- 6
For complex Pathfinder 2e logic, nested if-then conditionals can be more reliable than lookup-table approaches in DataViewJS.
- 7
Treat calculator outputs as unverified until checked, and re-prompt ChatGPT if the results don’t match the rules.