Skip to content

"Story and Passage API": Chapbook (v1.0.0)#


Often, it can be useful to access information about the story or other passages while it is running. In Chapbook, the engine.story object provides two functions, passageNamed() and passageWithId(), for accessing other passages. Combined with the [JavaScript] modifier, these functions and values they return when given existing passage names, can be used to show the name and source of one passage in another.



Twee Code#

:: StoryTitle
Chapbook: Story and Passage API

:: Start
The title of this story is "{}".

The title of this passage is "{}".

  // Find a passage by name
  let storagePassage = engine.story.passageNamed("Storage");

  // Write the name
  write('The name of the passage is "' + + '".<br>');

  // Write the source
  write('The name of the passage is "' + storagePassage.source + '".<br>');

:: Storage
This is content in the storage passage!

Twee Download