I was hoping to be able to blog a bit about Opinion objects and such today, but I didn’t get around to it last week. In fact, I did work on the dialog templates that went beyond what I talked about in the last blog.

Templates 2.0

The first version of dialog templates, which I discussed in the previous blog, involved creating a Dictionary of tags that would call functions to replace them with text. These functions could reference variables pertaining to the current conversation, or you could write a function that did whatever else you needed. That worked great!

And then I applied that methodology to the payloads being sent from the server for NPC responses, instead of just player text…

What I wound up doing was creating a generic tag that allowed the server to dump delimited text for filling in the dialog templates with values, and then simply filling in those tags as the template and server payload was read. Of course, as soon as I did this, I realized that I needed to add arguments to the generic tags so that we could prepend text to the data replacing the tag, as well as “alternate” text to stand in when data was missing (remember, Interrogative‘s system allows for missing information in dialog, so dialog templates should be written to account for this, or else you’ll get “artifacts” in your text rendering).

As mentioned above , the generic tags also support for when the server payload sends some arguments that are empty, and you have the option to use text to replace that (add punctuation or text as needed to patch up that space that would normally have information in it). Another feature I wound up implementing was the parsing of generic tags first and the original, specific, tags second. This was done so that you could actually nest the specific tags inside the generic ones and take advantage of those functions.

Again, it worked great! And then my brain continued down the rabbit-hole…

The current dialog templates will stand for now, as I tackle other parts of the conversation system, though I do have a planned expansion of it to bring more features into it, such as nested-tags and a cleaner format for inserting text for prepending and appending. Also, a bit of work remains with the architecture of this portion of the code itself (I try not to get sloppy, but sometimes you have to hack it in, take a step back and then revisit it to get it the way you want it).

But that’s not all I did this week…

I did work on a small technique and an additional predicate called “like”, which prompts a character to bring up objects that have a similar characteristic in a referenced line of dialog. So if you have a player talking to a character about Sunflowers and asks the character what’s similar to the color of it, you could get this (I do realize that for this example, the dialog template should reference the color being asked about):


This is a feature that will be needed for some more nifty dialog things down the road, but it was a piece of low-hanging fruit that I could knock off the list before returning to the twin beasts of Opinions and Statements.

Next blog: Well, I’ve been working on Statements and Responses since this stuff got done, so it will probably begin to delve into that subject. And that will likely be more than one blog, since it’s a fairly wide subject, touching on dialog templates, other conversation features, personality traits, and opinions. Stay tuned!