parsing

Provides a variety of different parsing tools for foundry ink. These assist in converting story text into actions performed by foundry or by installed modules.

Methods

(static) parseAltText(text, namesopt) → {undefined|Object}

Parses statements written in the form of DATA--ALTTEXT. This syntax is intended for use when data contains some text to show in the ink story once the data has been parsed out, so that text can be included in a compact format.

Parameters:
Name Type Attributes Default Description
text String

the text to be parsed

names Object <optional>
{ data: 'data', alttext: 'alttext' }

maps each of the regex groups to a name of your choosing, if specified.

Properties
Name Type Description
data String

the name of a group that identifies data to be dispatched for use by foundry.

alttext String

the name of a group that identifies what text to leave behind and emit through ink.

Returns:

the result of parsing. When the parse has failed, this will be undefined. Otherwise, it will be an object containing a named field for each element in the names parameter.

Type
undefined | Object

(static) parseInline(text, namesopt) → {undefined|Object}

Parses statements written in the form of COMMAND (TYPE): ARGUMENT. While writing a script, it is common to use inline statements to tag character dialogue, or to indicate scene/shot transitions. This syntax is intended for the ink story to control foundry.

Parameters:
Name Type Attributes Default Description
text String

the text to be parsed

names Object <optional>
{ command: 'command', type: 'type', argument: 'argument' }

maps each of the regex groups to a name of your choosing, if specified.

Properties
Name Type Description
command String

the name of the group that identifies the purpose of the text.

type String

the name of a group in parenthesis that provides additional information about the text, such as how an actor would say it, or what mood they are feeling.

argument String

the name of the group that the command and type operate on. This would ordinarily include an actor's dialogue, which scene to load, or filenames to prepare.

Returns:

the result of parsing. When the parse has failed, this will be undefined. Otherwise, it will be an object containing a named field for each element in the names parameter.

Type
undefined | Object

(static) parseInterface(text, namesopt) → {undefined|Object}

Parses statements written in the form of INTERFACE>>DATA. This syntax is intended for use when the ink story needs to wait for foundry to do something, such as fire a hook, before it is time to resume the story.

Parameters:
Name Type Attributes Default Description
text String

the text to be parsed

names Object <optional>
{ interface: 'interface', data: 'data' }

maps each of the regex groups to a name of your choosing, if specified.

Properties
Name Type Description
interface String

the name of a group that identifies which of foundry's internals the story should communicate with.

data String

the name of a group that identifies the configuration data foundry will need to establish the communication channel.

Returns:

the result of parsing. When the parse has failed, this will be undefined. Otherwise, it will be an object containing a named field for each element in the names parameter.

Type
undefined | Object