inkcpp
|
A runner to execute ink script from a story. More...
#include <runner.h>
Public Types | |
using | line_type = std::string |
Public Member Functions | |
virtual void | set_rng_seed (uint32_t seed)=0 |
Sets seed for PRNG used in runner. | |
virtual bool | move_to (hash_t path)=0 |
Moves the runner to the specified path. | |
virtual bool | can_continue () const =0 |
Can the runner continue? | |
virtual const char * | getline_alloc ()=0 |
Continue execution until the next newline, then allocate a c-style string with the output. | |
virtual snapshot * | create_snapshot () const =0 |
creates a snapshot containing the runner, globals and all other runners connected to the globals. | |
virtual line_type | getline ()=0 |
Execute the next line of the script. | |
virtual line_type | getall ()=0 |
Execute the script until the next choice or the end of the script. | |
virtual void | getline (std::ostream &)=0 |
Gets the next line of output using C++ STL string. | |
virtual void | getall (std::ostream &)=0 |
Gets all the text until the next choice or end. | |
virtual const choice * | begin () const =0 |
Choice iterator. | |
virtual const choice * | end () const =0 |
Terminal choice iterator. | |
virtual void | choose (size_t index)=0 |
Make a choice. | |
virtual bool | has_tags () const =0 |
Check if the current line has any tags. | |
virtual size_t | num_tags () const =0 |
Returns the number of tags on the current line. | |
virtual const char * | get_tag (size_t index) const =0 |
Access a tag by index. | |
virtual bool | has_global_tags () const =0 |
Check if the there are global tags. | |
virtual size_t | num_global_tags () const =0 |
Get Number of global tags. | |
virtual const char * | get_global_tag (size_t index) const =0 |
Access a global tag by index. | |
virtual bool | has_knot_tags () const =0 |
Check if there are knot/stitch tags. | |
virtual size_t | num_knot_tags () const =0 |
Get Number of knot/stitch tags. | |
virtual const char * | get_knot_tag (size_t index) const =0 |
Access a knot/stitch tag by index. | |
virtual hash_t | get_current_knot () const =0 |
Get hash of current knot/stitch name. | |
template<typename F > | |
void | bind (hash_t name, F function, bool lookaheadSafe=false) |
Binds an external callable to the runtime. | |
template<typename F > | |
void | bind (const char *name, F function, bool lookaheadSafe=false) |
Binds an external callable to the runtime. | |
template<typename D > | |
void | bind_delegate (hash_t name, D functionDelegate, bool lookaheadSafe) |
bind and unreal delegate | |
operator bool () const | |
Shortcut for checking if the runner can continue. | |
bool | has_choices () const |
Checks if we're currently facing any choices. | |
size_t | num_choices () const |
Returns the number of choices currently available. | |
const choice * | get_choice (size_t index) const |
Gets a choice. | |
const choice * | operator[] (size_t index) |
Shorcut for accessing a choice. | |
A runner to execute ink script from a story.
An independent runner which can execute ink script from a story independent of other runners. Think of the ink story object like an executable file and the runners as 'threads' (not to be confused with ink threads, which are a language feature). Runners track their own instruction pointer, choice list, temporary variables, callstack, etc. They can either be started with their own globals store, or can share one with other runner instances.
|
pure virtual |
Choice iterator.
Iterates over choices the runner is currently facing.
|
inline |
Binds an external callable to the runtime.
Given a name and a callable object, register this function to be called back from the ink runtime.
name | name string |
function | callable |
lookaheadSafe | if false stop glue lookahead if encounter this function this prevents double execution of external functions but can lead to missing glues |
|
inline |
Binds an external callable to the runtime.
Given a name and a callable object, register this function to be called back from the ink runtime.
beside an exact signature match, the function can also have one of the following signatures:
name | name hash |
function | callable |
lookaheadSafe | if false stop glue lookahead if encounter this function this prevents double execution of external functions but can lead to missing glues |
|
inline |
bind and unreal delegate
name | hash of external function name in ink script |
functionDelegate | |
lookaheadSafe | bind() |
|
pure virtual |
Can the runner continue?
Checks if the runner can continue execution. If it can't, we are either at a choice or are out of content.
|
pure virtual |
Make a choice.
Takes the choice at the given index and moves the instruction pointer to that branch.
index | index of the choice to make |
|
pure virtual |
creates a snapshot containing the runner, globals and all other runners connected to the globals.
|
pure virtual |
Terminal choice iterator.
Pointer past the last choice the runner is currently facing.
Gets a choice.
Returns the choice object at a given index
index | index of the choice to access |
|
pure virtual |
Get hash of current knot/stitch name.
|
pure virtual |
Access a global tag by index.
Global tags are placed at the top of the script instead of above or next to the current line. For tags related to the current line, use
index | tag id to fetch [0;num_global_tags()) |
|
pure virtual |
Access a knot/stitch tag by index.
Knot stitch tags are placed at the top of a knot/stitch.
index | tag id to fetch [0;num_knot_tags()) |
|
pure virtual |
Access a tag by index.
Note that this method only allows the retrieval of tags attached to the current line. For tags at the top of the script, use get_global_tag()
index | tag id to fetch [0;num_tags()) |
|
pure virtual |
Execute the script until the next choice or the end of the script.
Continue execution until the next choice or the story ends, then returns the output as an STL C++ std::string
or Unreal's FString
.
|
pure virtual |
Gets all the text until the next choice or end.
Continue execution until the next choice or the story ends, then return the output to an STL C++ std::ostream. Requires INK_ENABLE_STL
|
pure virtual |
Execute the next line of the script.
Continue execution until the next newline, then returns the output as an STL C++ std::string
or Unreal's FString
.
|
pure virtual |
Gets the next line of output using C++ STL string.
Continue execution until the next newline, then return the output to an STL C++ std::ostream. Requires INK_ENABLE_STL
|
pure virtual |
|
inline |
Checks if we're currently facing any choices.
|
pure virtual |
Check if the there are global tags.
|
pure virtual |
Check if there are knot/stitch tags.
@info knot/stitch tags are also assoziated to the first line in the knot/stitch
|
pure virtual |
Check if the current line has any tags.
Excludes global tags.
|
pure virtual |
Moves the runner to the specified path.
Clears any execution context and moves the runner to the content at the specified path.
path | path to search and move execution to |
size_t ink::runtime::runner_interface::num_choices | ( | ) | const |
Returns the number of choices currently available.
|
pure virtual |
Get Number of global tags.
@info global tags are also assoziated to the first line in the knot/stitch
|
pure virtual |
Get Number of knot/stitch tags.
@info knot/stitch tags are also assoziated to the first line in the knot/stitch
|
pure virtual |
Returns the number of tags on the current line.
Excludes global tags.
|
inline |
Shortcut for checking if the runner can continue.
Shorcut for accessing a choice.
index | index of the choice to access |
|
pure virtual |
Sets seed for PRNG used in runner.
Else runner is started with the current time as seed.
seed | seed to use for PRNG |