How I made the play script

My submission for the jam was The Show Must Go Down: https://ldjam.com/events/ludum-dare/49/the-show-must-go-down. Like most people, I didn't end up adding half of what I was planning, but overall I'm pretty proud of it. I had no idea before the jam started that I would be making anything like it, and I'd like to share a bit about how it came to be.

Outside the jam, I've been working on an adventure RPG. It's top-down-ish like many Zelda/Pokemon games, but using 3D visuals. I tried out some existing RPG tools in Unity, and none of them felt right for what I wanted to make. So I've been building some new tools, specifically a 3D tile map editor and a dialogue engine.

The other game (not my ldjam entry) (also, super early WIP): walking_stairs.png

I was initially planning on using this jam as a chance to put my tile map editor to use and develop that further. I ended up getting hooked on the second dumb idea I had after the jam started, which gave me a better opportunity to use the dialogue engine instead.

Unity has its timeline system for making cinematics, and I've seen node-based editors in RPG frameworks. But these were always too complicated for what I wanted. Many RPG interactions are very simple. An NPC says a line, nods their head, walks out of the room, etc. I played around with RenPy a bit and realized that was the kind of system I was looking for. RenPy is a visual novel engine, so definitely not going to work for my games, but I really like the way it has simple commands embedded into a text script. It makes it read almost like a screenplay. You define various characters and states/emotions they can be in, and then used very simple positioning. Example : show sylvie green smile at right. This gets parsed to show a certain image at a certain part of the screen, but you can tell at a glance what it does. If I can write a script like this, I can start cranking out scenes fairly quickly.

In my own system, each type of line is determined by its starting character:

  • Empty/whitespace lines are skipped
  • '#' is likewise skipped (for comments)
  • Lines starting with alphanumeric are treated as dialogue.
  • '>' is a command
  • ':' changes the speaker. Everything after a second colon on the same line is treated as a dialogue line.
  • '=' marks the following lines as conditional

The script reads the lines one by one in order. Here's an example:

```

position the actors on screen

move baddie centerRight move princess centerLeft look baddie princess look princess baddie

interaction for when baddie has the right prop

=6 holding baddie package :princess: Hast thou the parcel in thine hand? :baddie: Oh, uh, yeah. Let me just ...

openPackage baddie music baddieReveal Haha! You fool! anim princess slowDeath ```

And a demo of that second section of the script: princessemdeath/emanim.gif

This section of the dialogue only plays if the actor "baddie" is holding the item called "package". This was a horrible way to implement branching, because it made me count lines, and the "=6" is really confusing and seems like something else. But the branching was something I didn't implement until near the end of the jam, so I just hacked it together really quick. I'm definitely going to change that for my other game.

The other lines are fairly self explanatory. The first word of each command (the lines starting with '>') is the name of the command, and the following words are its parameters. In my dialogue script inspector, I defined a dictionary of actors and locations. These things can then be referenced by the script and used as parameters.

Overall, it worked pretty well, but I ended up adding some fairly specific commands (e.g. "openPackage") that won't make sense in my other game, so I need to revise things a bit to better cover all my use cases. There were several problems like that that that only came up when I put it to use in a quick project like this. So I'd say this jam has been an effective learning experience. Thanks everyone who played my game so far and left their feedback. I was worried that spending so much time on my tools was going to leave the game itself lacking (there's really not that much you as the player can do), but it sounds like people are enjoying it anyway.