inkcpp
Loading...
Searching...
No Matches
InkCPP Documentation

Inkle Ink C++ Runtime with INK.JSON -> Binary Compiler.
supports ussage in:

CMAKE usage

The current erlease is available at the release page, as <os>-lib.zip (e.g. linux-lib.zip).
to link the libraries you can use find_package(inkcpp CONFIG) which provides two targets:

  • inkcpp: the runtime enviroment
  • inkcpp_comopiler: functionality to compile a story.json to story.bin

To run your own .ink files you need a way to compile it to inks runtime format .ink.json. One way is to use inklecate <story>.ink.
Which is available at the official release page.

If you want to use the inkcpp with C link against the target inkcpp_c and #include <ink/c/inkcpp.h> The C-API documentation and example can be found here.

Exampl with library extracted at /YOUR/PROJECT/linux-lib And the Example project is extracted to /YOUR/PROJECT

cd /YOUR/PROJECT
ls # expected output: CMakeLists.txt main.cpp test.ink test.ink.json linux-lib
mkdir build
cd build
inkcpp_DIR=../linux-lib cmake ..
cmake --build .
cp ../test.ink.json .
./main_cpp

main.cpp

#include <ink/system.h>
#include <ink/choice.h>
#include <ink/runner.h>
#include <ink/story.h>
#include <ink/compiler.h>
#include <iostream>
using namespace ink::runtime;
int MyInkFunction(int a, int b) { return a + b; }
int main()
{
ink::compiler::run("test.ink.json", "test.bin");
// Load ink binary story, generated from the inkCPP compiler
story* myInk = story::from_file("test.bin");
// Create a new thread
runner thread = myInk->new_runner();
// Register external functions (glue automatically generated via templates)
thread->bind("my_ink_function", &MyInkFunction);
// Write to cout
while (thread->can_continue())
std::cout << thread->getline();
// Iterate choices
int id = 0;
for (const choice& c : *thread) {
std::cout << (id++) << ". " << c.text() << std::endl;
}
std::cin >> id;
thread->choose(id);
// Write to cout
while (thread->can_continue())
std::cout << thread->getline();
}
An ink choice that is being presented to the user.
Definition choice.h:32
Pointer wrapper to an object whose lifetime is tied to a story object.
Definition story_ptr.h:85
A loaded ink story.
Definition story.h:26
virtual runner new_runner(globals store=nullptr)=0
Creates a new runner.
void run(const char *filenameIn, const char *filenameOut, compilation_results *results=nullptr)
file -> file
Contaning all modules and classes used for the inkles ink runtime.
Definition choice.h:13

CMakeLists.txt

cmake_minimum_required(VERSION 3.16)
project(main)
find_package(inkcpp CONFIG REQUIRED)
# for CXX builds
add_executable(main_cpp main.cpp)
target_link_libraries(main_cpp inkcpp inkcpp_compiler)
# for C builds
# add_executable(main_c main.c)
# target_link_libraries(main_c inkcpp_c)

test.ink

EXTERNAL my_ink_function(a,b)
Hello world!
* Hello back!
Nice to hear from you!
* Bye
BTW 3 + 5 = {my_ink_function(3,5)}
-> END

compiled: test.ink.json

Unreal Installation

The current release is available at the release page, as unreal.zip.
Unpack this foldor in /PATH/TO/UNREAL_ENGINE/Engine/Plugins/ and it will be available as plugin in the plugin list.
Or unpack this folder in /PATH/TO/UNREAL_PROJECT/Plugins/ and it will be intigrated at the next startup.
A MarketPlace appearance is work in progress :)

The overview to the UE Blueprint class and examples can be found at here.

If you want to use the newest version clone the project and install the unreal component.

git clone https://github.com/JBenda/inkcpp
cd inkcpp
mkdir build
mkdir plugin
cd build
cmake ..
cmake --install . --component unreal --prefix ../plugin
cd ../plugin
# Should contain a folder named 'inkcpp'
cp -r inkcpp /PATH/TO/UNREAL_PROJECT/Plugins

Python example

You can install the current release from pypi with
pip install inkcpp-py.
Or build it yourself from main with:
pip install .

Here can you find an example inclusive story.

Python module documentation