Help on implementing "LPeg" or Ink into a Playdate Lua project

Hello everyone!

For a narrative game project I'm looking into using ink and Narrator a LUA parser for ink.

Problem is, while I know that Playdate LUA SDK replaced "require" with "import" I can't manage to find how to properly import this module. In Narrator, I managed to find and replace all occurrences of "require", but I have no idea on how to replace "LPeg" being used for parsing files.

I found LuLPeg, a fully LUA based implementation of it, but it ends up being the same nightmare, with me having no success on "converting" it.

Any pointer of a Playdate implementation of Ink? Or an implementation of LPeg that could work for Playdate?

@neven might be able to help you. In his game The Barkless Doctrine, if memory serves, he stores the story as a JSON file exported from a Lua table and uses Narrator to read that story back into the runtime.


I also tried to port these but failed.

I know one of the season games also tried but in the end wrote it's own dialogue system.

1 Like

Oh yeah! I just found the Reddit post where he mentions it! Reddit - Dive into anything

Tagging @james too if by any chance making this preprocessor available (paid or free) is a possibility :pray:

1 Like

Barkless does have a limited Ink parser and engine! It's not something that we're prepared to release to the public at this time however. I file a note to myself to look into what it would take to package it.


OK here's a zip of a slightly modified version of the ink engine. It includes

  • a python preprocessor to convert an Ink language file into a Lua table
  • the ink engine responsible for managing the backing store of text
  • the drawing code

The engine and the drawing code are completely decoupled so you should be able to use it on its own. Take a look at main.lua for how to drive it.

I can't really provide support for this so please take it and use it however you like.

Ink (43.5 KB)

/cc @neven


Thanks you so much for this! This will be SUPER helpful!

I'll have a closer look to see if I can expand it a bit to support some of my specific needs (variables, conditions, weaves and function calls).