ink language integration
Write interactive narratives using ink, a scripting language designed for branching stories, integrated with Pixi’VN.
Pixi’VN lets you write interactive narratives using ink, a scripting language designed for branching stories.
What is ink? ink is a simple scripting language for interactive stories, used in games like 80 Days, Heaven's Vault, and Sorcery! Learn more on the ink website.
The ink + Pixi’VN integration uses inkjs and PixiVNJson to parse ink code and generate JSON that Pixi’VN can interpret. This means JavaScript/TypeScript and ink share the same storage and canvas, and you can launch ink knots (or labels) from JavaScript/TypeScript and vice versa. You get the best of both worlds: write narration in ink, and use JavaScript/TypeScript for minigames or advanced animations.
=== start ===
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
* [We hurried home] -> hurry_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.
-> startWhy?
Writing narrative directly in JavaScript/TypeScript can be slow and complex, especially for beginners. ink is much easier to learn and write.
New developers can start with an ink template, then gradually learn JavaScript/TypeScript for advanced features.
설치
Templates
Starting a new Pixi’VN project? Use a template that already includes ink.
To install the ink package in an existing JavaScript project, use one of the following commands:
npm install @drincs/pixi-vn @drincs/pixi-vn-inkInitialize
After installing, use importInkText() to load your ink script:
import { importInkText } from '@drincs/pixi-vn-ink'
const inkText = `
=== start ===
Hello
-> END
`
importInkText([inkText, ...])Now you can run an ink knot (or label) using Pixi’VN functions:
import { narration } from '@drincs/pixi-vn'
narration.call(`start`, {})Upcoming features
These features are in development.
Show your interest by liking or commenting on the issues.
- Functions and Game Queries (#11):
- User-created functions (#32)
CHOICE_COUNT()TURNS()TURNS_SINCE()SEED_RANDOM()
LIST(#15)Tunnels(#38)
Syntax ignored by Pixi’VN
Some ink syntax is ignored by Pixi’VN. You can use these in your ink script (e.g., for testing in Inky editor), but Pixi’VN will ignore them.
INCLUDE
INCLUDE is an ink statement to include another ink file. In Pixi’VN, you should use importInkText() to load multiple ink files instead, so INCLUDE is ignored.
Narration outside the knots
Narration outside the knots (or labels) is ignored, except for variables.
For example:
VAR my_var = false // ✅ This will be handled (because it is a variable)
Hello // ❌ This will be ignored [!code warning]
-> start // ❌ This will be ignored [!code warning]
=== start === // ✅ This will be handled
My name is John // ✅ This will be handled
-> DONE // ✅ This will be handled