A Lua implementation of ink.
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.
See WritingWithInk and RunningYourInk for the reference ink documentation.
To use it in your project download the latest source. 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('examples/game.ink')
while true do
-- 2) Game content, line by line
while story.canContinue do
io.write(story.continue())
end
-- 3) Display story.currentChoices list, allow player to choose one
if #story.currentChoices == 0 then break end -- cannot continue and there are no choices
for i = 1, #story.currentChoices do
print(i .. "> " .. story.currentChoices[i].text)
end
local answer=io.read()
story.chooseChoiceIndex(answer)
endSee 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
or just:
$ examples/game.lua
And this example shows LÖVE integration:
$ love examples/love2d
$ ./test/test.sh # all tests
$ ./test/test.sh I129 # run a single test case
$ ./test/test.sh W1.3.* # run test cases mathing a pattern
- More tests - source: premek/ink-proof