inkcpp
Loading...
Searching...
No Matches
HInkRunner Class Reference

A handle for an ink runner. More...

#include <inkcpp.h>

Public Types

typedef InkValue(* InkExternalFunction) (int argc, const InkValue argv[])
 Callback for a Ink external function which returns void.
 
typedef void(* InkExternalFunctionVoid) (int argc, const InkValue argv[])
 Callback for a Ink external function wihich returns a value.
 

Public Member Functions

void ink_runner_delete (HInkRunner *self)
 Deconstructs the Runner and all frees assoziated resources.
 
HInkSnapshotink_runner_create_snapshot (const HInkRunner *self)
 Creates a snapshot, for later reloading.
 
int ink_runner_can_continue (const HInkRunner *self)
 Can the runner continue?
 
const char * ink_runner_get_line (HInkRunner *self)
 Continue execution until the next newline, then allocate a c-style string with the output.
 
int ink_runner_num_tags (const HInkRunner *self)
 return the number of current.
 
const char * ink_runner_tag (const HInkRunner *self, int index)
 access tag.
 
int ink_runner_num_choices (const HInkRunner *self)
 Returns the number of choices currently available.
 
const HInkChoiceink_runner_get_choice (const HInkRunner *self, int index)
 Gets a choice.
 
void ink_runner_choose (HInkRunner *self, int index)
 Make a choice.
 
void ink_runner_bind_void (HInkRunner *self, const char *function_name, InkExternalFunctionVoid callback, int lookaheadSafe)
 Binds a external function which is called form the runtime, with no return value.
 
void ink_runner_bind (HInkRunner *self, const char *function_name, InkExternalFunction callback, int lookaheadSafe)
 Binds a external function which is called from the runtime, with a return vallue.
 

Detailed Description

A handle for an ink runner.

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.

See also
globals
story

Member Typedef Documentation

◆ InkExternalFunction

typedef InkValue(* InkExternalFunction) (int argc, const InkValue argv[])

Callback for a Ink external function which returns void.

Parameters
argcnumber of arguments
argvarray containing the arguments

◆ InkExternalFunctionVoid

typedef void(* InkExternalFunctionVoid) (int argc, const InkValue argv[])

Callback for a Ink external function wihich returns a value.

Parameters
argcnumber of arguments
argvarray contaning the arguments
Returns
value to be furthe process by the ink runtime

Member Function Documentation

◆ ink_runner_bind()

void ink_runner_bind ( HInkRunner * self,
const char * function_name,
InkExternalFunction callback,
int lookaheadSafe )

Binds a external function which is called from the runtime, with a return vallue.

See also
ink_runner_bind_void()
Parameters
self
function_namename of external function declared inside ink script
callback
lookaheadSafeif false stop glue lookahead if encounter this function this prevents double execution of external functions but can lead to missing glues

◆ ink_runner_bind_void()

void ink_runner_bind_void ( HInkRunner * self,
const char * function_name,
InkExternalFunctionVoid callback,
int lookaheadSafe )

Binds a external function which is called form the runtime, with no return value.

See also
ink_runner_bind()
Parameters
self
function_namedeclared in ink script
callback
lookaheadSafeif false stop glue lookahead if encounter this function this prevents double execution of external functions but can lead to missing glues

◆ ink_runner_can_continue()

int ink_runner_can_continue ( const HInkRunner * self)

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.

See also
continue
has_choices
Returns
Can continue be called

◆ ink_runner_choose()

void ink_runner_choose ( HInkRunner * self,
int index )

Make a choice.

Takes the choice at the given index and moves the instruction pointer to that branch.

Parameters
indexindex of the choice to make
self

◆ ink_runner_create_snapshot()

HInkSnapshot * ink_runner_create_snapshot ( const HInkRunner * self)

Creates a snapshot, for later reloading.

Attention
All runners assoziated with the same globals will create the same snapshot HInkSnapshot

◆ ink_runner_get_choice()

const HInkChoice * ink_runner_get_choice ( const HInkRunner * self,
int index )

Gets a choice.

Returns the choice object at a given index

See also
num_choices
Parameters
indexindex of the choice to access
Returns
choice object with info on the choice
Parameters
self

◆ ink_runner_get_line()

const char * ink_runner_get_line ( HInkRunner * self)

Continue execution until the next newline, then allocate a c-style string with the output.

This allocated string is managed by the runtime and will be deleted at the next choose() or getline()

Returns
allocated c-style string with the output of a single line of execution

◆ ink_runner_num_choices()

int ink_runner_num_choices ( const HInkRunner * self)

Returns the number of choices currently available.

Returns
number of choices
Parameters
self

◆ ink_runner_num_tags()

int ink_runner_num_tags ( const HInkRunner * self)

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

◆ ink_runner_tag()

const char * ink_runner_tag ( const HInkRunner * self,
int index )

access tag.

Parameters
indextag id to fetch [0;num_tags())
self

The documentation for this class was generated from the following file: