inkcpp
|
A runner to execute ink script from a story. More...
#include <runner.h>
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 std::string | getline ()=0 |
Gets the next line of output using C++ STL string. | |
virtual void | getline (std::ostream &)=0 |
Gets the next line of output using C++ STL string. | |
virtual std::string | getall ()=0 |
Gets all the text until the next choice or end. | |
virtual void | getall (std::ostream &)=0 |
Gets all the text until the next choice or end. | |
virtual FString | getline ()=0 |
Gets the next line of output using unreal string allocation. | |
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 since last choice selection tags have been added | |
virtual size_t | num_tags () const =0 |
return the number of current. | |
virtual const char * | get_tag (size_t index) const =0 |
access tag. | |
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 independant runner which can execute ink script from a story independant 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 |
access tag.
index | tag id to fetch [0;num_tags()) |
|
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 as an STL C++ std::string. Requires INK_ENABLE_STL
|
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 |
Gets the next line of output using C++ STL string.
Continue execution until the next newline, then return the output as an STL C++ std::string. Requires INK_ENABLE_STL
|
pure virtual |
Gets the next line of output using unreal string allocation.
Continue execution until the next newline, then return the output as an Unreal FString. Requires INK_ENABLE_UNREAL
|
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 |
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 |
return the number of current.
The tags will be accumulated since last choice order of tags wont change, and new are added at the end
|
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 |