Thursday 1 May 2014

Declaring Variables, Sets and Relations

In the current version of StoryTeller, the author must write JavaScript code in order to declare variables, sets and relations.

Examples:

Variables:

variables = [
    {name: "boolVar", value: new BooleanVariable(true)},
    {name : "numVar", value: new NumberVariable(3.14159) },    
    { name : "intVar", value: new IntegerVariable(0, 65536, 0, false) },
];

Sets:

var characters = new Set(
    {name: "Dick Dastardly"},
    {name: "Muttley"},
    {name: "Penelope Pitstop"}
)

var items = new Set(
    {name: "rolling pin", "damage": 1, "sound": "crack"},
    {name: "plank", "damage": 3, "sound": "thwack"},
    {name: "golf club", "damage": 6, "sound": "clunk"},
    {name: "kitana", "damage": 10, "sound", "woosh"}
);

sets = [
    {name: "characters ", set: characters},
    {name: "items", set: items}
];

Relations:

relations = [
    {name: "isHolding", relation: new Relation(people,items)}
];

There's a few problems with this.

  1. Lots of brackets and words are needed.
  2. It's easy to make errors and being JavaScript they can be hard to find and fix.
  3. It will be hard to parse when I write the GUI.

Due to this. I'm planning on implementing another way to declare these things (and probably removing the ability to define them with JavaScript). Authors will declare variables, sets and relations in the body of the html document, in divs marked with an attribute like data-init="variables".

Variables would look like this:

<div data-init="variables">
    boolVar: BooleanVariable(true);
    numVar: NumberVariable(3.14159);
    intVar: IntegerVariable(0, 65536, 0, false);
</div>

Relations would look like this:

<div data-init="relations">
    isHolding: characters, items;
</div>

However, I'm currently stuck on how to define sets. Sets with no extra information attached (like the characters set above) can easily be written in a manner similar to the relations:

<div data-init="sets">
    characters: "Dick Dastardly", "Muttley", "Penelope Pitstop";
</div>

...but attaching extra data (like "damage" and "sound" for the items set) is messier. The best I can come up with is to lay it out like a table:

 <div data-init="sets">
      items       ("damage", "sound"):
    {"rolling pin",  1,      "crack"},
    {"plank",        3,      "thwack"},
    {"golf club",    6,      "clunk"},
    {"kitana",      10,      "woosh"};
</div>

This doesn't seem completely right. It would be easy to make mistakes and the meaning of the symbols isn't really clear.

If you have any opinions or ideas on this please comment, either here or in the subreddit

Monday 28 April 2014

Version 0.3 Released

If you have already started using StoryTeller this update will definitely break your stories. However, the changes required to fix them are simple.

Pages are no longer specified with class="page" and id="{pageId}". Now only a single attribute is needed data-page-id="{pageId}". Any div with this attribute will be recognised as a page.

Simliarly, class="storyteller" will no longer work. The equivalent is data-viewport-id="main".

New Features:

  • List functions
  • Multiple viewports


Tuesday 22 April 2014

Version 0.21 Released

I made an executive decision and removed the @(...) notation for lists so that I can use the @ symbol as a projection operator.

Just to limit the amount of time v0.2 is left in the wild with the old notation, I've released a minor update.

This update only includes 2 changes:

  1. The @(...) list notation has been replaced with {...} (curly brackets)
  2. The projection operator (see the documentation for lists) 

Re-purposing the @ operator

I'm currently adding a "projection" operator to work with lists. I will allow you to extract a single item from the list (like retrieving a value from an array by its index) or a subset of the items.

I'm considering using the @ symbol for this because it is read as "at". It would sort-of make sense ('a','b','c','d','e')@3 could be read as ('a','b','c','d','e') at index 3. ('a','b','c','d','e')@(0,1,4) would be ('a','b','c','d','e') at indices 0,1 and 4.

This would mean its current use, to mark single value lists, would be disabled. I am already introducing a better way to write lists in the next version so no functionality will be lost but if anyone has used the @ operator already then their stories will break if they upgrade to the next version.

The alternative is to keep the @ operator as it is and use a different symbol. I'm considering the colon ':'

If you have an opinion please share it, either in the comments or the subreddit

Friday 18 April 2014

Subreddit

I've created a subreddit for StoryTeller.

If you would like to discuss anything about the project or share your own stories please head over there

Version 0.2 Released


A new version of StoryTeller has been released. This version adds support for lists, iteration, sets and relations.

Lists

A list is an ordered collection of values. You can define a list by separating the values with commas. For example: (1,2,3,4,5).

Loops

The foreach statement can be used to repeat part of a page once for each value in a list.

Sets

A set is a group of things. For example the set of characters in your story.

In StoryTeller, sets also serve as lookup tables. Each member of a set can have values associated with it in key-value pairs.

Relations

A relation describes some fact for all of the members of one or more sets. One example is a relation between the sets of characters and objects in a story which describes whether or not a character is holding a particular item.

download the new version