One of the things I have been exploring more recently is a minimum DSL for story sifting. I came up with replicating JavaScript’s conditional statements and keywords (along with some English shortcuts) in a project named Quis. It isn’t quite at a 1.0 stage yet, but the DSL part has solid testing by itself without an associated project to demonstrate its abilities.
Twine passage metadata
Throughout work on the new Twine 2 JSON format, I was thinking about the metadata issue. Both Twee 3 and Twine 2 JSON formats support metadata
properties as key-value pairs for passages. This means it is possible to add any DSL string values, and have a library or parser understand and act on them. (Both YarnSpinner and Dendry have the ability to add arbitrary fields/properties to story units, as two examples of implementations.)
The current issue is lack of direct access to passage metadata in Twine itself. Something I have floated to a couple of people more privately is adding a “Metadata” option to the editor toolbar when working in Twine. This would allow an author to add any key-value pairs they want, and potentially story formats could act on them to enable emergent narrative design patterns (like storylets, microstories, and story sifting approaches).
While I’d like to tackle this myself, I anticipate needing to focus on a new job in early 2024. That written, here are the steps as I see them to get this done:
-
Adding storage object and functionality to internal Twine data for keeping track of each passage’s
metadata
properties. -
Add “Metadata” menu option to passage editing toolbar with associated UI functionality for adding, changing, and removing key-value pairs.
-
Updating Twine 2 HTML specification for encoding key-values pairs within the
<tw-passagedata>
element.
Potentially, this could take different forms. Two approaches I have thought about include the following:
(A) Encoding metadata as JSON string with metadata
attribute per passage:
<tw-passagedata
pid="1"
name="Start"
tags="tag1 tag2"
position="102,99"
size="100,100"
metadata="{'name':'John', 'age':30, 'car':null}">
Some content
</tw-passagedata>
(B) Following pattern of <tw-tag>
based on HTML <data>
element with using name
as the name of the passage:
<tw-metadata name="Start">
<data value="John">name</data>
<data value="30">age</data>
<data value="null">car</data>
</tw-metadata>