npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@drincs/pixi-vn-ink

v0.2.3

Published

Pixi'VN gives you the ability to write your own narrative using Ink

Downloads

326

Readme

Ink Language Integration

Pixi’VN gives you the ability to write your own narrative using Ink.

What is ink?

Ink is a scripting language for writing interactive narrative. It is used in games like 80 Days, Heaven's Vault, and Sorcery! to create branching stories.

This language is very simple to learn, you can learn the basics in a few minutes. Go on ink website to learn more about it.

Why use Ink integration?

Programming a game narrative in Javascript/Typescript has the advantage of having total development freedom, but the disadvantage is that it slows down the writing of a narrative (it makes you write a lot of code).

Ink is a language that allows you to write a narrative easily, without having to write a lot of code. Plus, it only takes you about ten minutes to learn the basic functions. Ink is basically designed only for writing narratives, so it doesn't require a canvas or other features outside of narrative.

Launching narrative labels (or knots) from Javascript/Typescript to Ink sharing the same memory and canvas is a double benefit. You can use Ink to write the narration, while using Javascript/Typescript to handle everything that is not possible with Ink.

Furthermore, novice developers can use a template to start writing narratives with Ink. After becoming familiar with Javascript/Typescript they can start to create more laborious features, like minigames or complex animations.

Start using Ink in Pixi’VN

If you have not created a project yet then it is recommended to use the template and select a template that is based on ink.

Otherwise to add ink to your Pixi’VN project you need to install the @drincs/pixi-vn-ink package.

# npm
npm install @drincs/pixi-vn-ink

# yarn
yarn add @drincs/pixi-vn-ink

# pnpm
pnpm add @drincs/pixi-vn-ink

# bun
bun add @drincs/pixi-vn-ink

After installing the package you need to import the importInkText() function from the package and use it to import the ink script into your project.

// main.ts
import { importInkText } from '@drincs/pixi-vn-ink'

const inkText = `
=== start ===
Hello
-> END
`

importInkText([inkText, ...])

Now you can run the start knot (or label) with Pixi’VN functions.

narration.callLabel(`start`, {})

Import text contained in .ink files

( This method has been tested only on projects generated with vitejs )

To import text contained in .ink files you need create the file ink.d.ts:

// src/ink.d.ts
declare module '*.ink' {
    const value: string
    export default value
}

After that you need to add the .ink extension to the assetsInclude option in the vite.config.ts file:

// vite.config.ts
export default defineConfig({
  // ...
  assetsInclude: ['**/*.ink'],
})

After that you can import the ink file and add ?raw at the end of the import to get the text content.

// main.ts
import { importInkText } from '@drincs/pixi-vn-ink'
import startLabel from './ink_labels/start.ink?raw'

importInkText([startLabel, ...])

Ink features in development

The following features are in development and will be added in the future:

( Add a like or comment to the issue to show your interest in the feature )

Ink syntax that will be ignored by Pixi’VN

The following syntax will be ignored by Pixi’VN (They will not create errors).

INCLUDE

INCLUDE is used by Ink to import other ink files.

In Pixi’VN you can use the importInkText() function to import the ink files. So if you use INCLUDE it will not be handled, so it does not import the files.

Narration outside the knots

The narration outside the knots (or labels) will be ignored. The reason is that as explained by Pixi’VN you can't start a whole ink file, but you have to use this functions for run a knot (or label).

So for example the following cases will be ignored:

Hello # ❌ This will be ignored
-> start # ❌ This will be ignored
=== start === # ✅ This will be handled
My name is John # ✅ This will be handled
-> DONE # ✅ This will be handled

Using Pixi’VN Features from Ink