Ignore the fact that my data is completely made up, but here’s my current iteration of my TTRPG “Locations system”. I call it a system because it’s actually, maybe, three or four files and at least four plugins worth of work just to get it looking and working like this.

The Setup

As per my previous post, I’ve got the following plugins:

  • Templater, for on-demand actions.
  • Meta Bind, for form elements and taking actions with buttons.
  • Data View, for querying files and metadata in the vault and displaying it in various ways.

I’m also using the ITS Theme which gives it a really nice face-lift, and provides the “Wikipedia-like” sidebar on the right-hand side of the page.

Specialty files

The base file is called Location Template and it looks a little something like this in its raw form:

This is the “editing” view, and is more or less what you’ll get when you’re filling out the Overview and History sections, unless I decide to try something else. It’s important to know that this file does not get used as-is. Instead, it will be copied to other documents. The code at the top is for Templater.

Next I have a Javascript file, newLocation.js:

This file is called to copy the template to a new location as a new note.

Finally, there’s the inline code in the Location Template file. The first is for the sidebar:

Next, we have markup for the “Add Sub-Location” button section:

And then the dataview which displays locations which are “children” of the current location:

And finally, the Maps button and display code:

Workflow

When looking at all of the pieces, there’s nothing to recommend a natural starting point. If I were opening this vault for the first time and wanted to create a new location, what do I do?


Before we go anywhere, I need to mention that there’s at least two important settings that need to be set for this all to work.

The first is “Trigger Templater on new file creation”, which will execute any Templater code in any templates we use, and “Folder templates” which will create a new note in the specified folder using the specified template.


With the above settings turned on and the folder location set to use the Location Template file as the basis for new notes in that folder, I would simply right click on the 2. The World/Locations folder in the Vault and choose “New Note”.

Templater code

There’s some Templater code at the top of the Location Template file, and we need it to execute when this template is used to create a new note…this is why we turned on the “Trigger Templater on new file creation” option. It will also trigger when using the Right Click > New Note option because of the other setting we enacted, “Folder templates”.

This does two things. First, it will create a new note with the name “Untitled”, but will also immediately pop up a text entry box asking for a better file name. Entering this and pressing ENTER will change the file name and the note’s title.

It also takes some calculated information and stores it in the newly created file’s front matter. Front matter is an in-file data store, or metadata section, at the top of the file. Here, we’re taking the name of the document which spawned this document and storing it in the metadata as the document’s parent. The Tags metadata is an old and unused line so disregard it. The parent metadata will come into play in a bit; it doesn’t make a lot of sense when we’re creating a file using the Right Click > New Note option because it has no parent document.

Editing the new note

The easiest way to start editing is to just open the new note. At this point, I can put the cursor almost anywhere and start entering data. The “Editing Mode” is the only one which will allow me to enter Overview and History information. However, there are some elements which will also work in “Reading Mode”.

In Reading Mode I can add a sub-location, add maps, choose a banner image, and modify the demographics by using the form elements provided by Meta Bind. In the case of images and demographics, the metadata (seen at the top in this screenshot) is updated immediately. In the case of adding sub-locations, it’s a bit more complex.

Sub-locations

Remember when I added a new location using the Right Click > New Note method? I can still do that, but once I have some top-level locations defined, I can create related locations which exist inside the bounds of that location such as a city in a country, or a dungeon inside of a kingdom.

When pressing the “Add Sub-Location” button, the newLocation.js file is executed. This will take the name of the current file and create a sub-folder in the file’s directory. Then it will create a new file in that folder using the Location Template file as a base. The Templater code in the template will fire, asking us to name the new sub-location, and will set the parent metadata of the new file to the name of the spawning file…i.e. “the parent location”.

This last bit is important because the “Places of Note” section also includes a Dataview component which looks into the sibling folder of the currently viewed file of the same name. It then adds any files inside that folder to the dataview.

In this image, “Solomon Island” is at the root of “2. The World/Locations”. I used the “Add Sub-Location” button and created “Kingsmouth”. The system created the sub-folder “Solomon Island” for the new document. I added 2 more locations from the “Solomon Island” page — “Savage Coast” and “Blue Mountain” — which were also added to the sub-folder. Because all three of those documents have a parent metadata value of “The World/Locations/Solomon Island.md”, they show up in the “Places of Note” dataview table on the “Solomon Island” page.

If I click on the “Savage Coast” note, we’ll see there’s a sub-location “Reds Bait and Tackle” listed there

Why!?

I’m asking myself the same damn question. See, I could create just a Templater template which is nothing but a normally designed form. No sidebar, no fancy metadata, no buttons or textboxes or data views. Thing is, Obsidian is good, but it’s not that good when it comes to allowing me to organize content. Sure, I could rely on custom CSS, but that’s a different and parallel journey I do not wish to undertake. The way I’ve structured things allows for data to be presented where and in ways that make sense for me, and isn’t just a series of ungainly blocks of paragraphs set off by differently sized headers…like this blog post!

The ideal situation would be to have these pages as forms which I would then lock down so I couldn’t edit their underlying structure. I could use textboxes or textareas to enter long-form text, or select boxes to limit my choices to either hard-coded lists or lists derived from dataview queries. Buttons would allow me to spawn sub-notes, like with sub-locations, so I wouldn’t have to use the sidebar to add new notes except when adding the very first note to a folder. Rather than switch in and out of edit and reading mode, I’d like to have one single usable mode, made possible through plugins and templates.

I’d say that the location system is in a fairly good place, but isn’t without its faults. For example, what if I need to move “Solomon Island” to become a child of another location? That would require a new top-level document, and a new sub-folder named after that new document. Then, “Solomon Island” and all of its children and grandchildren and so on would have to move…and have their data updated. I don’t have an automated way to do this, sadly.

It’s also been a long time coming to get to this point. As I have started in previous posts, nothing is ever as easy as it really should be, and I won’t beat that drum any more in this post.

Was it worth it?

I have absolutely no idea. I won’t know until I actually try to use it beyond test cases. I expect at that point that I’ll come across some data I’ll wish I had thought of earlier, as I’ll no doubt have to shoe-horn it into several already-made notes to ensure parity. But I think that the setup I have right now is a very good starting point for other “systems” like NPCs, items, and encounters. I haven’t exactly memorized the code conventions I used for Meta Bind, Dataview, and Templater, so I’m sure I’ll still haunt their docs going forward, but I’m hoping that this work will pan out to be worthwhile, for me at least.

Scopique

Husband, father, gamer, developer, and curator of 10,000 unfinished projects.