Saturday 13 June 2020

A generator of generators!?

Generators in the OSR sphere are largely JavaScript-based. It's easy to see why -- JS is immediately accessible, it lets you create dynamic web pages (or snippets for web pages), and it's fucking everywhere. But, as with all great things, there are downsides to the JS generators we've grown to know and love.

They're cumbersome. Like, so, so, so cumbersome. I'm not gonna name names or link you to any of them, but ... yeah. Some of them require you to host your text files elsewhere. Others require you to use extremely specific syntax but offer no validation of them ("test extensively" is not a validation). Others still offer hosting but you can't edit your own generators after having them hosted. Many offer you a blob of javascript you can add to your blog and get a sample output from.

My immediate goal was "I want dynamic table results", rather than "I need to fix everything" or something like that. I wanted to be able to write "2d6 orcs advance slowly down the side of the ravine" and have the output be "3 orcs advance slowly down the side of the ravine"; I figured that was a good place to start. You could make a JS page that just scanned the text for dice rolls and replaced them.

I've still not gotten anywhere near that. I made something else instead. I made a fucking generator. Quelle surprise, I guess, since the title is "A generator of generators!?" and I'm talking about ... well, yeah.

This tool, though, I had a mission statement for. It's a bit undefined around the edges, but overall it looks something like this:

Cassie's Generator Tool
  • The syntax should be clear and concise
  • Hosting for both the generator and the tables (lists) should be a solved problem for the user
  • Users should be able to edit their own tables if they need to
  • Users should be able to delete their own tables and generators, if they want to 
  • You should be able to use generators or tables someone else has made
  • It should offer embedding, no unsightly JS blob
  • If the user wants to, they should be able to download all their generators and tables
Here's a first sketch of the syntax:
A table result: {{table}}
A generator result: ||generator||
Dice notation: >1d6<, >1d6+2<
I'm still not sure about the dice notation, but I think it's important to have the difference between what should be rolled and what is information for the reader:
"The weapon does 1d6 damage" should just say "The weapon does 1d6 damage" in the output, whereas "The next >1d4< days" should say "The next 2 days" (plural "days" is gonna be a problem. Hm.)

I've not implemented everything yet. In fact, I've only solved the boring parts. But the good parts are coming. Here's what I made yesterday:
Now, that "{{11}}" says nothing, I know. I'll think of something. Eventually, there'll be helper functions for writing generator entries (like, you'd write {{ and get a search window to find the table you want a result from), but for now there's nothing like that.

The way the code's written, a generator is simply a very thin wrapper around a parser and a transformer, so using generators within other generators should be pretty easy. A few issues loom on the horizon, though. If I become as popular as Facebook, I can't host everything for free, and there might be some resource issues along with that popularity. I might have to move the platform to kubernetes eventually, just for that horizontal scaling. And also because I want to learn it.

Today and tomorrow I'll set up the embed thing, and then I think I might even link to the thing for public consumption.

No comments:

Post a Comment

Rust

 I'm going to learn Rust. I mean, I mostly already know it, but I want to have a clear goal to strive for, so here goes: Gain an underst...