Sha256: a67e4ea7141ac1a98d1e24321fb9f8c575540a817b3fc6ff8dd768511d71fa78

Contents?: true

Size: 925 Bytes

Versions: 4

Compression:

Stored size: 925 Bytes

Contents

#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();
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
inkcpp_rb-0.1.3 ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp
inkcpp_rb-0.1.2 ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp
inkcpp_rb-0.1.1 ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp
inkcpp_rb-0.1.0 ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp