-
Notifications
You must be signed in to change notification settings - Fork 3
Creating Scene Content
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 (//-----------------------------
)
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
}
]
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"]
},
The id of the fragment, which can be called directly by choices via "gotoId". Must be unique.
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.
Whether a fragment can be used multiple times. Value is either true or false.
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
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 use two main linking methods:
-
gotoId
: an explicit link to another fragment (which must have achoiceLabel
)
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 effectset introCompleted true
)
What needs to be true in the State for this fragment to be valid.
Condition syntax
Changes to the state run when this fragment is displayed.
Effects syntax