Loreline

loreline.Loreline (Class)

The main public API for Loreline runtime. Provides easy access to the core functionality for parsing and running Loreline scripts.

Static Members

parse(input: String, ?filePath: String, ?handleFile: Null<ImportsFileHandler>, ?callback: Function): Null<Script>

Parses the given text input and creates an executable Script instance from it.

This is the first step in working with a Loreline script. The returned Script object can then be passed to methods play() or resume().

Name Type Default Description
input String The Loreline script content as a string (.lor format)
filePath String (optional) (optional) The file path of the input being parsed. If provided, requires handleFile as well.
handleFile Null<ImportsFileHandler> (optional) * (optional) A file handler to read imports. If that handler is asynchronous, then parse() method will return null and callback argument should be used to get the final script
callback Function (optional) If provided, will be called with the resulting script as argument. Mostly useful when reading file imports asynchronously
Returns Description
Null<Script> The parsed script as an AST Script instance (if loaded synchronously)

play(script: Script, handleDialogue: DialogueHandler, handleChoice: ChoiceHandler, handleFinish: FinishHandler, ?beatName: String, ?options: InterpreterOptions): Interpreter

Starts playing a Loreline script from the beginning or a specific beat.

This function takes care of initializing the interpreter and starting execution immediately. You'll need to provide handlers for dialogues, choices, and script completion.

Name Type Default Description
script Script The parsed script (result from parse())
handleDialogue DialogueHandler Function called when dialogue text should be displayed
handleChoice ChoiceHandler Function called when player needs to make a choice
handleFinish FinishHandler Function called when script execution completes
beatName String (optional) Optional name of a specific beat to start from (defaults to first beat)
options InterpreterOptions (optional) Additional options
Returns Description
Interpreter The interpreter instance that is running the script

resume(script: Script, handleDialogue: DialogueHandler, handleChoice: ChoiceHandler, handleFinish: FinishHandler, saveData: SaveData, ?beatName: String, ?options: InterpreterOptions): Interpreter

Resumes a previously saved Loreline script from its saved state.

This allows you to continue a story from the exact point where it was saved, restoring all state variables, choices, and player progress.

Name Type Default Description
script Script The parsed script (result from parse())
handleDialogue DialogueHandler Function called when dialogue text should be displayed
handleChoice ChoiceHandler Function called when player needs to make a choice
handleFinish FinishHandler Function called when script execution completes
saveData SaveData The saved game data (typically from interpreter.save())
beatName String (optional) Optional beat name to override where to resume from
options InterpreterOptions (optional)
Returns Description
Interpreter The interpreter instance that is running the script

Metadata

Name Parameters
:hxGen -