Fork 0
mirror of https://github.com/Oreolek/ink-instead.git synced 2024-05-29 14:28:17 +03:00
Go to file
2018-04-24 15:31:27 +07:00
examples story.state.visitCountAtPathString 2016-12-31 00:27:11 +01:00
pink trying to make an ink module 2018-04-24 15:31:27 +07:00
test gather parser, todo: runtime, gather+divert 2017-08-20 18:39:52 +02:00
.gitignore fix runtime for when knot is next 2017-01-13 20:36:12 +01:00
.travis.yml Update .travis.yml 2017-06-26 01:47:16 +02:00
LICENSE Create LICENSE 2016-12-11 02:41:17 +01:00
lpeg.so trying to make an ink module 2018-04-24 15:31:27 +07:00
main3.lua trying to make an ink module 2018-04-24 15:31:27 +07:00
README.md Update README.md 2017-08-20 18:39:34 +02:00
test.ink trying to make an ink module 2018-04-24 15:31:27 +07:00



An attempt to implement a subset of ink in lua using lpeg

Ink is inkle's scripting language for writing interactive narrative, both for text-centric games as well as more graphical games that contain highly branching stories.



  • Paragraphs
  • Comments
  • Choices
    • choice and output text
    • nested choices
  • Knots
  • Diverts
  • Glue
  • Include
  • Tags

Runtime API


boolean story.canContinue
string story.continue()
table story.currentChoices
nil story.chooseChoiceIndex(index)
nil story.choosePathString(path)
table story.globalTags
table story.tagsForContentAtPath(path)
table story.currentTags
number story.state.visitCountAtPathString(path)


string story.state.toJson()
nil story.state.loadJson(savedJson)
story.variablesState["variable_name"] = newValue
value = story.variablesState["variable_name"]
story.observeVariable ("variable_name", function(string varName, object newValue) ) 
story.bindExternalFunction ("function_name", function(...))

See WritingWithInk and RunningYourInk for the description of the reference ink implementation.

Used by

pink is used by my small game https://github.com/premek/enjoy

Let me know if you want to use it too - or just use it!

Install dependencies

Install luarocks (Or see https://luarocks.org/#quick-start for instructions for other platforms):

sudo aptitude install luarocks

Install lpeg:

luarocks install --local lpeg

Get pink:

Clone this repo or download an archive from releases page. You need just the pink subdirectory.

Note on dependencies

The pink parser depends on lpeg which can easily be instaled by luarocks (see above) but it may be difficult to distribute it with your game for each platform (it is a C library). Please consider compiling the .ink file into lua table, save it into a file and distribute just the compiled file with a lua table instead of compiling at runtime. (See: #3)

Pink runtime is just a pure lua.

How to use this to run a game

To use it in your project download the latest source or the latest release. You need just the pink directory.


Given some .ink file like below, you can easily run it in your lua application using the pink library.

=== back_in_london ===
We arrived into London at 9.45pm exactly.
*   "There is not a moment to lose!"[] I declared. -> hurry_outside
*   "Monsieur, let us savour this moment!"[] I declared.
    My master clouted me firmly around the head and dragged me out of the door.
    -> dragged_outside

=== hurry_outside ===
We hurried home to Savile Row  -> as_fast_as_we_could

=== dragged_outside ===
He insisted that we hurried home to Savile Row
-> as_fast_as_we_could

=== as_fast_as_we_could ===
<> as fast as we could.
local pink = require('pink.pink')
-- 1) Load story
local story = pink.getStory('examples/game.ink')
while true do
  -- 2) Game content, line by line
  while story.canContinue do
  -- 3) Display story.currentChoices list, allow player to choose one
  for i = 1, #story.currentChoices do
    print(i .. "> " .. story.currentChoices[i].text)
  if #story.currentChoices == 0 then break end -- cannot continue and there are no choices
  local answer=io.read()
  print (story.currentChoices[tonumber(answer)].choiceText)

See the examples directory for a simple text based example and a LÖVE integration.

This is how to run the text-based example:

$ lua examples/game.lua

And this example shows LÖVE integration:

$ love examples/love2d

How to run tests

$ lua test/test.lua