InkCaller is an API to call Ink. Each new call is independent and can be executing concurrently

inkcaller

This library

InkCaller is an API to call Ink. Each new call is independent and can be executing concurrently.
A call will force the ink state, (optional) set the seed, (optional) set the knot, (optional) answer a previous choice.
A call returns the current ink state (to inject into the next call). This state can be decoded to get the text, the choices.
This does not allow all the features of ink (e.g. no callback or external function).

Depending on your design, Ink will need to interact with the game model. Set needed data inside ink state in the input. Use formatted text and a parser for the actions.

InkTranslator is a helper to decode the json ink state.

Example

Example using directly the inkcallerv8

ctx := context.Background()
caller := inkcallerv8.NewInkCallerV8()

//first call, we don't have any ink state to provide yet.
//we also want to set the seed.
//this is going to return the top part (introduction) from the ink file.

seed := inkcaller.Seed(2)
stateEncoded, err := caller.Call(ctx, "ink.js", "story.json", &seed, nil, nil, nil)
if err != nil {panic(err)}

//second call, use stateEncoded from the previous call.
//go to knot
//make a choice
choice := inkcaller.ChoiceIndex(0)
knotName := inkcaller.KnotName("Hub")
stateEncoded, err = caller.Call(ctx, "ink.js", "story.json", nil, stateEncoded, &knotName, &choice)
if err != nil {panic(err)}

Example using the translator, decoding the state

The translator package guides the possible operations and decodes the ink state into a go struct. This is using inkcallerv8 as a dependency (or any mock for easy integration tests).

ctx := context.Background()
caller := inkcallerv8.NewInkCallerV8()
translator := inktranslator.NewInkTranslator(caller)

seed := inkcaller.Seed(2)
inkState, inkStateEncoded, err := translator.BeginStory(ctx, "ink.js", "story.json", &seed)
if err != nil {panic(err)}
fmt.Println(inkState.OutputStream)

knotName := inkcaller.KnotName("Hub")
//A variable "Level" is declared in the ink file, overriding its value. 
gameData:= map[string]interface{}{"Level":"5"}
inkState, inkStateEncoded, err = translator.GoToKnot(ctx, "ink.js", "story.json", *inkStateEncoded, gameData, knotName)
if err != nil {panic(err)}
fmt.Println(inkState.CurrentChoices[0].Text)

What is ink?

"Ink" is a narrative scripting language for games. https://www.inklestudios.com/ink/

This is redacted in a story.ink source file. Then it can be exported for web: story.js + ink.js.
Quick Start Ink: https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md

Inkle projects and related:

License

MIT

Similar Resources

Automate all the tasks you can do in NeteaseCloudMusic

Fuck163MusicTasks 自动完成网易云音乐人任务并领取云豆 说白了就是白嫖网易云年费黑胶 ✨ 特性 web/Android 双平台每日签到 音乐人每日签到(登录音乐人中心) 自动发布动态(音乐人每日任务) 自动回复粉丝评论(音乐人每日任务) 自动恢复粉丝私信(音乐人每日任务) 自动领取已

Jan 5, 2023

This repository shows how can we use `AWS Lambda` to build serverless applications in golang.

Serverless Api in Go with AWS Lambda Here we are going to use AWS Lambda to build serverless applications in golang. Prerequisites You’ll need an AWS

Nov 3, 2021

This is a small Go program, which can tell you what processes are actively using a set of files

winuse This is a small Go program, which can tell you what processes are actively using a set of files. It primarily exists to show off how one can bi

Jan 28, 2022

lambda-go-api-proxy makes it easy to port APIs written with Go frameworks such as Gin to AWS Lambda and Amazon API Gateway.

aws-lambda-go-api-proxy makes it easy to run Golang APIs written with frameworks such as Gin with AWS Lambda and Amazon API Gateway.

Jan 6, 2023

💾 Wolke API is the API behind Wolke image storage and processing aswell as user management

💾 Wolke API Wolke API is the API behind Wolke image storage and processing aswell as user management Deploying To deploy Wolke Bot you'll need podman

Dec 21, 2021

A cloud native Identity & Access Proxy / API (IAP) and Access Control Decision API

Heimdall Heimdall is inspired by Ory's OAthkeeper, tries however to resolve the functional limitations of that product by also building on a more mode

Jan 6, 2023

Go library for accessing the MyAnimeList API: http://myanimelist.net/modules.php?go=api

go-myanimelist go-myanimelist is a Go client library for accessing the MyAnimeList API. Project Status The MyAnimeList API has been stable for years a

Sep 28, 2022

Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Oct 6, 2022

An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Dec 30, 2022
Clusterpedia-client - clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Jan 7, 2022
Client-go - Clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Dec 5, 2022
This is the new api repository for Feel the Movies. Written in Go, totally open source.
This is the new api repository for Feel the Movies. Written in Go, totally open source.

This is the new API repository for Feel the Movies. Written in Go, totally open source. App Currently available for Android only. I have plans for an

Sep 18, 2022
Create a new OpenAPI based blink-plugin

OpenAPI plugin template Create a new OpenAPI based blink-plugin. READ FIRST Getting the Repo Option 1: From Github Press Use this template Naming conv

Oct 14, 2021
Fedora-new-install - Utility scripts for a clean fedora installation

fedora-new-install Utility scripts for a clean fedora installation new-install.g

Nov 8, 2022
With this small library you can interact with the timev2 API

Library for timev2 With this small library you can interact with the timev2 API.

Jan 28, 2022
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Feb 6, 2022
Authorization can be hard, and this project aims to be simple solution to general authz problems.

racl (rest access control lists) Motivation Authorization can be hard, and this project aims to be simple solution to general authz problems. Mainly,

Nov 9, 2021
A note taking app, that you can draw in, syncs to the cloud, and is on most platforms!

About NotDraw About · How to contribute · How to run · Trello · FAQ This is achived because I dont want to work on it anymore Structure Codebase Descr

Jul 11, 2022
A API scanner written in GOLANG to scan files recursively and look for API keys and IDs.

GO FIND APIS _____ ____ ______ _____ _ _ _____ _____ _____ _____ / ____|/ __ \ | ____|_ _| \ | | __ \ /\ | __ \_

Oct 25, 2021