Skip to content

Creating Scene Content

Logodaedalus edited this page Dec 10, 2018 · 12 revisions

Summary

Content files are where you put all the fragments that can be assembled together to present to the player. This is where the writing lives, and this is where you set up the majority of the choice dynamics for your piece.

If you're trying this for the first time, your best bet is to open up the example.json file in js/StoryAssembler/data/scene-content and see how it works, and even just duplicate it and change the values (but be careful you step through each fragment and update it for your scene, especially the effects).

Because we use HanSON to parse it, you can use // to comment the file (as in example.json). Especially with content files, it's a good idea to put a plain-English description of what a fragment or group of fragments are doing, so you can track down where to change things more easily later. You can visually segment things by just putting a comment line in (//-----------------------------)


Data Structure

This file is just a big array of JS objects. Therefore, you should start and end it with square brackets, and each fragment should start and end with curly braces. Example:

[  
  {  
    //first fragment code  
  },  
  {  
    //second fragment code  
  }  
]

Example Fragment

Here's an example fragment, with links to each property description:

{
  "id" : "exampleFragment",
  "avatar": "friend1",
  "repeatable" : true,
  "choiceLabel" : "Show me an example.",
  "content" : "This is an example fragment, which is terribly exciting!",
  "choices" : [
    { "gotoId" : "staticChoiceExample" },
    { "condition" : "demoDynamicChoice eq true" }
  ],
  "conditions" : [ "introCompleted eq false" ],
  "effects" : [ "set introCompleted true", "incr readerKnowledge 1"]
},

Fragment Fields

id

The id of the fragment, which can be called directly by choices via "gotoId". Must be unique.

avatar

The avatar to display when this fragment is displayed. This is only pertinent if you've set "avatarMode" in Coordinator.js to "oneMain". Otherwise you can ignore it.

repeatable

Whether a fragment can be used multiple times. Value is either true or false.

choiceLabel

If a fragment can link here, what the label should be. Fragments without this field can never connect as choices, but if the story has reached the end of a particular choice structure, it will look for "base level" fragments to go to next, and hook them together via a "Continue" link.

  • You can use templates to make this field text dynamic
  • You can use conditional linking to make this field dynamic

content

This is the main body of text displayed.

  • You can use templates to make this field text dynamic
  • You can use conditional linking to make this field dynamic

choices

Choices use two main linking methods:

  • gotoId: an explicit link to another fragment (which must have a choiceLabel)
    Example: { "gotoId" : "prologue4" }
  • condition: let the system dynamically find a fragment with a choiceLabel that satisfies the condition.
    Example: { "condition" : "introCompleted eq true" }
    (will pick a fragment with an effect set introCompleted true)

conditions

What needs to be true in the State for this fragment to be valid.
Condition syntax

effects

Changes to the state run when this fragment is displayed.
Effects syntax