Quest 5.4 Text Processor – easier adaptive text and links

It is very easy to generate and manipulate text with software, which is why text adventures were some of the very first computer games ever to be created. Furthermore, the manipulation of words can make it easier for a text-based game to feel as if it is genuinely responding to the player’s actions – it is far simpler for software to tweak a paragraph of text than it is to tweak a graphical environment.

As the player interacts with a game, they can of course make choices which affect the outcome of the story – choosing which branch of a narrative to follow – but it is also possible to construct a game where the player is not so much directing the action as simply telling the game a bit more about themselves. An interactive game doesn’t necessarily mean that the player decides on the outcome – the effects could be more subtle than that. A character may say slightly different things to the player depending on what happened earlier in the game, for example, but this may not have any effect on anything else that happens.

So, it’s important for a text game engine to make it easy to generate adaptive text. Quest does a lot of this already without an author having to do anything – it will automatically generate a list of objects that are in the current room, for example. But anything more advanced than that generally has required the use of scripts. If you want to show a particular sentence only if the player has performed some action, you have to run an “if” script to print that sentence. The sentence will stand on its own, with a line break before and after, so this is more of a mechanism for complete paragraphs than it is for minor details within text.

It’s also harder than it should be to display object hyperlinks. These hyperlinks are a key way that players interact with games, and get displayed automatically as part of the room description, but it’s hard to easily “linkify” an object that you make a passing reference to in a paragraph. That’s because you have to be running a script again, and use the ObjectLink function in an expression.

Quest 5.4 addresses these issues with a new feature, the text processor. This is a core library function, so it’s implemented entirely in Quest’s own ASL programming language, and it steps in at the last moment, just before text is written to the screen. This means you can include text processor codes anywhere in your game – you can use the codes inside a “print message” script command, but you can also use them inside a plain-text object description. This makes it much easier to have dynamically generated text without having to create a script.

For example, here’s how we might write a description of a hungry mouse:

Text Processor - editing

We’re just using a text description here, not a script. The editor provides some helpful buttons so we don’t have to remember the available codes, and we can also easily add object links by clicking the “Object link” button – we can choose an object from the list that appears.

When we run the game, here’s what we see. The “Aaargh, a mouse!” text only appears the first time:

Text Processor - output

We can easily include conditional text using the {if} code, which allows us to check the value of game or object attributes. For example, if we’re looking at an apple and the player’s health is low, we might write:

That looks like a tasty apple. {if<10:It would be a very good idea to eat it.}

Using the {command} code, we could actually improve this and give the player an “eat apple” link. You can nest codes inside each other, so the link will only appear if the player’s health is low:

That looks like a tasty apple. {if<10:It would be a very good idea to {command:eat apple:eat it}.}

There is also the {random} code which allows you to choose text at random, and {img} lets you include images in-line with text.

The Quest 5.4 Beta release is very close now, but if you just can’t wait you can try out the nightly build.

6 thoughts on “Quest 5.4 Text Processor – easier adaptive text and links

  1. Pingback: Bringing more power to gamebook mode in Quest 5.4 | Text Adventures Blog

  2. Jay Nabonne

    I assume (or hope) the answer to this is yes, but can you also just print out variables and attributes in your text? That is a big reason I have to use scripts, is when assembling text to output based on the current state of variables (e.g. a room number or the alias for an object which has been passed as a function parameter).

    Looks cool so far! 🙂

    1. Alex Warren

      You can write an object attribute using {object.attribute}.

      There’s no way the text processor could read a local variable though as it’s a separate ASL function, so you’d have to write the variable to an attribute first (or just concatenate strings as you do now).

      1. jaynabonne

        Ok, I see. That should be good enough.

        What might be handy down the road would be a string formatting function separate from msg, where you would have the same string syntax but perhaps also pass in params (like for eval). You’d pass in a format string and optional params and get a string back. I know… feature creep. 🙂

        Looking forward to trying this out!

  3. Pingback: Quest 5.4 Beta is out now | Text Adventures Blog

  4. Pingback: Quest 5.4 released | Text Adventures Blog

Comments are closed.