Main engine API, with functions for you to load your story and build rules.
The framework takes care of managing all of the state, views, and interaction handling, allowing the client code to focus purely on the story.
Basic information about the story, which gets displayed on the "title page" before beginning the story.
info : Info
info =
{ title = "The Continuing Adventures of Bartholomew Barrymore"
, byline = "B. Barrymore"
, prologue = "Mr. Barrymore is at it again, with more shenanigans in this comedy-mystery..."
}Information for the starting state of your story. See the "Changing the story world" section for more information on the setupCommands.
setup : StartingState MyItem MyLocation MyCharacter MyKnowledge
setup =
{ startingScene = beginning
, startingLocation = Home
, startingNarration = "Home sweet home..."
, setupCommands =
[ addLocation Conservatory
, moveCharacter John Conservatory
, placeItem Umbrella Home
]
}A means of looking up static information about your story interactables, which gets loaded into Story.load.
A collection of all of the interactable elements in your story, for loading into the engine.
Display information for your items, including a name and description. The description allows markdown.
itemInfo "Umbrella" "My trusty umbrella, I take it everywhere."Display information for your locations, including a name, a highlight color, and a description. The description allows markdown.
locationInfo "Home" Color.Green "Home sweet home..."Display information for your characters, including a name and description. The description allows markdown.
characterInfo "Harry" "My good friend Harry..."Rules are how you progress the story. They are made up of conditions to match against and commands to perform if the rule matches. Rules are grouped into "scenes" for better control and organization. The engine will run through the active scene from the beginning, looking for the first matching rule, then run it. If no rules match, the framework will perform a default command, which is usually just to narrate the description of what was interacted with.
A rule has four parts:
When a rule matches multiple times (a player clicks the same story element multiple times), it will run through the list of narrations in order, one per click, repeating the final one when it reaches the end.
A declarative rule, describing how to advance your story and under what conditions.
The following interaction matchers can be used in the interaction part of the rule record.
Will only match the interaction part of a story rule if the player interacted with the specified item.
Will only match the interaction part of a story rule if the player interacted with the specified location.
Will only match the interaction part of a story rule if the player interacted with the specified character.
Will match the interaction part of a story rule every time (be careful about the the order and conditions of your rules since this matcher is so broad).
Will match the interaction part of a story rule if the player interacted with any item (be careful about the the order and conditions of your rules since this matcher is so broad).
Will match the interaction part of a story rule if the player interacted with any location (be careful about the the order and conditions of your rules since this matcher is so broad).
Will match the interaction part of a story rule if the player interacted with any character (be careful about the the order and conditions of your rules since this matcher is so broad).
The following condition matchers can be used in the conditions part of the rule record.
Will only match if the supplied item is in the inventory.
Will only match if the supplied character in in the current location.
Will only match if the supplied item is in the current location. Ignores inventory.
Will only match when the supplied location is the current location.
Will only match if the specified knowledge has been acquired.
Will only match if the supplied condition does NOT match.
You cannot change the story directly, but you can supply "commands" describing how the story state should change.
Changes the current location. The current location will be highlighted in the list of known locations, and will also be displayed at the top of the page, highlighted in the color defined for that location. Any items or characters that are in the current location will also be shown for the player to interact with.
Adds a location to your list of known locations. Any location on this list is available for the player to click on at any time. This avoids clunky spatial navigation mechanics, but does mean that you will need to make rules to prevent against going to locations that are inaccessible (with appropriate narration).
Removes a location from your list of known locations. You probably don't need this since once you know about a location you would always know about it, and trying to go to a location that is inaccessible for some reason could just give some narration telling why. But maybe you will find a good reason to use it.
Adds an item to your inventory (if it was previously in a location, it will be removed from there, as items can only be in one place at once).
Removes an item from your inventory. The item will not show up anywhere until you add it back to your inventory or to a location.
Adds a character to a location, or moves a character to a different location (characters can only be in one location at a time, or off-screen). (Use moveTo to move yourself between locations.)
Moves a character "off-screen". The character will not show up in any locations until you use moveCharacter again.
Move an item to a location. If it was in another location or your inventory before, it will remove it from there, as items can only be in one place at once.
Moves an item "off-screen" (either from a location or the inventory). The item will not show up in any locations or inventory until you use placeItem or addInventory again.
Knowledge is an intangible "flag" that you can match against in your rules. For example if you add knowledge of learning about a suspect, then going back to people you have already interacted with can give you new information about the suspect when you interact with them again. You can also use this for acquiring skills or bonuses or anything intangible that would not be displayed in the story. You could track your actions, such as if you were kind or mean to an important character in an earlier scene.
However, before turning to this tool, consider if you can use a normal, story interactable instead. For example, perhaps you get a sketch of the suspect in your inventory, which you can "show" to people for more information. This keeps the story more concrete.
type MyKnowledge = LearnOfSuspect | WrongSuspect | Amnesia
addKnowledge LearnOfSuspectRules are grouped into "scenes" for better organization and control. This is how you switch between scenes when you want a different rule set. You may want to switch scenes at a "turning point" in your story to bring about new rules for the next objective.
scene1 = [...rules here...]
scene2 = [...rules here...]
-- in the `changes` part of a rule in a scene1:
loadScene scene2Let the framework know the story has ended. Currently this has no effect, I'm trying to figure out what should happen when stories end. You may want to make the rule load a special "storyFinished" scene that only has one withAnything interaction matcher so the player can't do anything else (unless you want to let them "wander").
This is where you load all of your story details into the framework (from the client's
Main.elmfile). See https://github.com/jschomay/elm-interactive-story-starter.git for an example of how to define interactables and scenes.