Ink(y) / Porting the Ink compiler to the browser?

I know very little about porting c# apps to the browser, so I thought I’d ask here and hope there’s someone more knowledgeable than me willing to answer.

How hard would it be to port the Ink compiler from C# to the browser (JavaScript or Webassembly)? Possibly not rewriting the whole thing from scratch, but doing it (semi-)automatically via some kind of transpiler.

Ink games already run in the browser, of course, but it would be cool to move the whole stack to the browser, so to speak. Building on that you could create an Inky editor that runs entirely client-side in the browser, for example.

Hello Daniel,
You’ll be very happy to know that :slightly_smiling_face: … it’s been done already !
We’re in the final stages of releasing inkjs with the parser+compiler : GitHub - y-lohse/inkjs at compiler (there are some last issues to iron), and you are more than welcome to contribute a PR to speed up the process a little.

I’m also writing a web adaptation of inky (but this is far from done) : GitHub - smwhr/inkyweb (with a way to try it here : Inky Web but beware) : it’s not production ready and may break anytime but I’m already using it on a regular basis to test some ink on the go. Here, feel free to PR also if you want to contribute !

6 Likes

(By the way : we translated the C# quite litteraly to typescript, this is maybe very time consuming, but lessons learnt from the player/engine part : this is really easy to port subsequent commits by the inkle team when they develop on the C# project)

1 Like

Wow, this is great! Thank you so much for this! I’ll start playing with it right away.

Also, someone on inkle’s discord made a prototype for use with Eleventy (most of the conversation takes place over there, I can send you an invite if you wish)

Is it possible to make a design request?

Please could you make it possible to turn off that little box attached to the cursor making typing completion suggestions? I found it made it impossible for me to think about what I was actually trying to type, because it was always exactly where I was looking. Plus it was also a nuisance when I hit return to start a new paragraph, and it thought I wanted the completion it was suggesting.

Thanks! :slight_smile:

1 Like

This is now official, inkjs 2.1.0, out just now, offers a build that includes the ink compiler :partying_face:

It means you can do things like :

const story  = (new inkjs.Compiler(`Hello World`)).Compile()
// story is an inkjs.Story that can be played right away

const jsonBytecode = story.ToJson();
// the generated json can be further re-used

instead of having to compile your ink files locally. Everything works in the browser.

@chance_the_ripper have you had time to play with the partial build ?

6 Likes

While, not directly the same situation here, I’ve added an ink engine into a web server (quickbbs – on GitHub bschollnick/quickbbs)

I’m releasing v4.2 very shortly (end of this week) that includes the ink engine, and various bug fixes.

1 Like

Can you show/link to what it looks like in action?

Which compiler are you using? js or c# ? Server side ?

Can you show/link to what it looks like in action?

Still very much in a bit of flux… But yes… Right now, in the process of converting some non-INK native IF to test and discover bugs…

Which compiler are you using? js or c# ? Server side ?

Well quickbbs itself is a Django server (Python using the Django framework), so neither JS or C#.

The ink engine, is a green field python rewrite based off the ink design specs, and I am currently working on the EXTERNAL feature, building out 3 (or more) included APIs for the ink system…

  • scheduling - Game scheduling, when an event should occur, is in game time a weekend, weekday, AM, afternoon, evening, etc.
  • location - multiple levels of functionality, up to being able to locate characters, place characters in “rooms”, etc.
  • skills - completely configurable for skills test

I’ve included several screen shots of the “The Intercept”, which is one of the examples from the ink engine… And one with graphics from one of the games I’ve converted to ink to help test out the ink engine..

I’m probably not going to met my deadline for this weekend, simply because I am still making significant changes. I had considered a feature freeze, but I’m not at a safe point to do so.

The code in GitHub is got the intended v4.2 release, so feel free to grab it, if you’d like to take a closer look.

-- Edit – Well, evidently the forum won’t allow me to include graphics in the post? I’ll try to update the readme on GitHub today or tomorrow? Weird, I can’t include URLs, and I can’t post images…

Hi, and welcome!

The forum puts some restrictions on new users; I don’t know the exact criteria for this instance (here’s an overview of the default settings), but you can usually get to the next “trust level” by reading a few different threads.

Here’s at least the link to the github repo, for convenience:

Thanks for posting that. I just put in the discussion area, specifically discussion # 362, the screen shots, and quick summary of the upcoming Interactive Fiction support.

Let’s see if I can post a link yet… Nope..

So follow the link above, click on discussions, and it should be the top discussion titled “New Feature - Interactive Fiction”. It includes the screens shots, and details as I mentioned previously.

I have started to move the python based Ink_Engine into its own repo. It’s now an entirely stand-alone embeddable engine. So QuickBBS is actually using it as well…

Now in addition, I’ve created a stand-alone IF Player. Currently only supports ink (inkj actually), the repo is in the works, it’s python powered, and using pywebview for the UI layer. I’m still in the testing stage for the stand-alone player.

The ink engine has the following available plugins that can be used in ink based games:

  • Characters (a structure to store specific details for character aka attributes, inventory, skills, etc)

  • character occupancy (1) - Builds onto of the location tracking, to add person/characters to the world

  • containers - items that specifically can “contain” an inventory (e.g. box, bag, chest, car, etc)

  • costs (2)

  • inventory (2) - used by characters, containers, etc to store inventory (either boolean, and/or Quantity based)

  • item descriptions (2) - used by the item & inventory system for examining items

  • location tracking - used for tracking where a location is in the world (1)

  • quests / quest tracking - fairly obvious

  • scheduling (1) - Builds on location tracking, character occupancy, to supply characters with a schedule (e.g. Doctor Jones is in the office M-F 8-11, 12-5, in the diner at m-f 11-12, at home 5:30 pm - 7:30 am)

  • skills / attributes - allow characters to actually track their personal skill levels and attributes - These are generic data stores, the engine doesn’t enforce any particular skill or attribute, that is up to the game to decide. Attributes also don’t necessarily mean “Dexterity”, “Charisma”, you the developer decide what the attribute is. In one case, I’m using attributes for “plot level stage”, where the player’s character is actually tracking their own successes / failures in the plot.

    Another NPC Character, is tracking their own plot points as well in an attribute field.

If anyone has suggestions for other pre-built externals that might be useful, please feel free to suggest them.

Edit:

  • To be clear, the ink_engine is available on GitHub right now.
  • I hope to have the stand-alone player out within the next couple of weeks. I need to play test, and brainstorm any additional features that I might want to add.
  • My ink engine is reverse engineered from the inkles ink reference document, and direct output comparison between the official compiler and my engine. I have not used any of their source code, so it is a clean reverse engineering effort.
  • But this also means that I can add features like image and movie support, as I mentioned earlier. These options are available through the ink engine, QuickBBS, and (soon) with the Stand-alone player.

And no, these are not commercial products. The ink engine needs to be battle tested by more people, and the stand-alone player could use the wheels kicked as well when it’s ready.