#Ink - A Narrative Scripting Language

1 messages Β· Page 1 of 1 (latest)

sick tinsel
#

I've been implementing the Ink language, designed by Inkle Studios, in Zig. The project is still experimental, with some known bugs that I'm currently working on. Any feedback is apprieciated! πŸ˜„

Much of the compiler design is ripped straight out of the Zig compiler internals.

https://codeberg.org/haxolotl/ink

warm vigil
#

I am working on a very similar effort, maybe we should join forces? πŸ˜ƒ

sick tinsel
#

lets talk over DMs

plush prism
#

Can you please explain what this is to people not familiar with Inkle ?

sick tinsel
#

Yes of course. Ink is a narrative scripting language for games. Dialogue for games is typically written in data-interchange formats such as JSON/XML, or via visual scripting such as Unreal Blueprints. Ink takes a third approach, allowing writers to write dialogue as if they were writing a screenplay, and bridging the gap between writers and programmers.

#

Out of the box, it is fully capable of building text adventure games through its CLI. Though the core library can be integrated into Unity, Unreal and Godot as middleware to build out dialogue and quest systems as seen in many JRPGs

#

It does not replace the need for a general purpose language such as C++, C# or Zig but relieves much of the effort required by writers and game designers to work on story and narrative.

#

The original implementation was written in C#, but after an experimental C99 port, I've decided to port it all over to Zig and drastically improve the performance and developer experience 😁

sharp wasp
#

are you the author of the original?

sick tinsel
#

I am not. That would be Jon Ingold and Joseph Humphrey

#

I am just a rando who wanted to integrate it into my own game engine and saw an opportunity for a fun project

#

I am in no way affiliated with Inkle

gritty herald
#

This is pretty cool. I am using Ink for my game, in particular the Dink dialect which compiles to normal Ink. I am currently using inkcpp to execute the scripts, but a native Zig runtime would be very cool (even if it's probably too late for me to switch runtimes at this point).

umbral bear
#

curiously enough, I'm also looking into this!
ink's canonical compiler compiles to json, and the runtime (written in javascript) reads that json output (as far as I understand)
does your implementation provides a complete package (as in, you feed a ink file to play the game) or is there a intermediate format?

sick tinsel
#

My project is aiming to be the entire package. A compiler, runtime and even possibly providing additional tools for development.

One of the most radical changes I've been working on is using a bytecode file format natively instead of JSON. Personally, I don't have any plans to support the JSON format, though I am open to anyone who wants to make a codegen for it based on the semantic IR format we have going. From my perspective, you should just be able to load files into memory with minimal parsing.

Speaking of JavaScript... There are two functional (full featured) runtimes that I'm aware of, one in C# and one in JavaScript. They both consume the same format. There are other efforts such InkCpp which consume Inkle's JSON format and translate it into a more efficient bytecode format. Seeing the part of the Ink community using engines like Unreal favor that approach made the path forward clear to me.

If a Javascript runtime was needed, for usage in the browser, I imagine you would be able to compile the project to WebAssembly. In the worst case scenario, where you would need a native JavaScript runtime... the current bytecode format is much simpler than the JSON format, so building a custom runtime that consumes the bytecode will not be difficult. Maybe that should be one of my TODOs.

#

We are still a few months out from having some very important features, such as snapshots, INCLUDE, EXTERNAL but I am getting some good results in my personal game dev projects

#

Also this isn't just a port for the sake of porting. There are some issues in the original language which I have fixed or am in the process of fixing. The compiler does simple though useful optimizations out of the box and error messages will be much more informative.

warm vigil
umbral bear
sick tinsel
#

Ink has some strange semantics that probably wouldn't translate well to Zig. Right now, the best solution (I'm totally not biased) is to have a very minimal runtime that has decent introspection

umbral bear
#

you're probably right. really cool work, nice job, I'll play around with it when i find time

sick tinsel
#

Thank you! 😁

#

If you plan on integrating the library into a project, I will be your personal tech support whenever something isn't working the way it should! πŸ˜„

sick tinsel
#

I'm currently working on a substantial refactor for declarations. After that gets pushed, I will be opening issues for all features planned for the first release as well as all known bugs/crashes.

umbral bear
#

since you're preparing to open issues, I found an error when adding the project as a dependency, building crashes because build.zig line 130 panics when there's no examples dir. A just-make-it-work patch is straightforward:

diff --git a/build.zig b/build.zig
index 290774a..3fa0ddb 100644
--- a/build.zig
+++ b/build.zig
@@ -127,10 +127,10 @@ fn buildExamples(
     var steps: std.ArrayList(*std.Build.Step.Compile) = .empty;
     defer steps.deinit(gpa);

-    var dir = try std.Io.Dir.cwd().openDir(io, try b.build_root.join(
+    var dir = std.Io.Dir.cwd().openDir(io, try b.build_root.join(
         gpa,
         &.{"examples"},
-    ), .{ .iterate = true });
+    ), .{ .iterate = true }) catch return steps.toOwnedSlice(gpa);
     defer dir.close(io);

     var it = dir.iterate();

#

fixed on my side and ran a couple hello world examples, worked without a hitch :)

sick tinsel
#

@umbral bear Thank you for reporting the issue. This will be addressed right after I push the code for the current task.

sick tinsel
#

Patched

sick tinsel
#

Support for visit counts and turn offets should be in master by the weekend or early next week.

I have a full time job whilst working on this πŸ˜…

warm vigil
sick tinsel
warm vigil
sick tinsel
#

The way that the C# Ink does snapshots is hilariously inefficient, so I've been doing research on how to do it better. There are papers all over my desk for design stuff lol

warm vigil
sick tinsel
#

Maybe after I finish making the best hecking implementation of Ink humanity has ever seen, I can return to working on the project I was building this for πŸ˜„

last pulsar
#

Opened a pr for a draft snapshots implementation, though probably want the gc to land first if you decide to go this direction.

sick tinsel
#

Sorry for the delay. I am clearing my backlog for the project and will incorporate what I can once I get the chance

last pulsar
#

No worries! It may not be how you were thinking of taking it, so feel free to just close it too