Description
Changelog
Reviews (0)

GDRS Ink

An Ink by Inkle implementation.

Ink is an amazing portable scripting language for scripting stories. It has been used to tell all kinds of game stories from pure Visual Novels to Adventure games.

This implementation is built on Rust-compiled GDExtension. It works for Window+Linux desktop, Web, and Android. Mac builds are possible, but you'll have to compile that yourself.

A Visual Novel example and an Adventure game style example are included.

Ink Example

- I looked at Monsieur Fogg 
*   ... and I could contain myself no longer.
    'What is the purpose of our journey, Monsieur?'
    'A wager,' he replied.
    * *     'A wager!'[] I returned.
            He nodded. 
            * * *   'But surely that is foolishness!'
            * * *  'A most serious matter then!'
            - - -   He nodded again.
            * * *   'But can we win?'
                    'That is what we will endeavour to find out,' he answered.
            * * *   'A modest wager, I trust?'
                    'Twenty thousand pounds,' he replied, quite flatly.
            * * *   I asked nothing further of him then[.], and after a final, polite cough, he offered nothing more to me. <>
    * *     'Ah[.'],' I replied, uncertain what I thought.
    - -     After that, <>
*   ... but I said nothing[] and <> 
- we passed the day in silence.
- -> END

A larger example exists on ink_file.ink

GDScript Sample

extends Node

@export_file("*.ink") var file
var first_button:bool = true

signal next()

func _ready() -> void:
    # Load the story data and create a InkStory for it.
    var story_text := FileAccess.get_file_as_string(file)
    var story := InkStory.from_ink(story_text)
    # Continue until the story is "finished"
    while story.story_can_continue():
        %text.text = story.continue_story()
        # If there are choices, provide those a buttons
        var choices := story.get_current_choices()
        if choices.size() != 0:
            for c in choices:
                if c.tags.size() != 0:
                    print(c.tags)
                make_button(story,c.text,c.index)
        # If there are not choices, we create a continue button.
        else:
            make_button(story,"[continue]",-1)
        # Wait for the button press
        await next

# Make a button that can trigger continue.
func make_button(story:InkStory,text:String,choice:int):
    var b := Button.new()
    b.text = text
    b.pressed.connect(choice_made.bind(story,choice))
    %choices.add_child(b)
    if first_button:
        # Use this to grab focus on the first option so you can just play with a keyboard.
        first_button = false
        b.grab_focus()

# Choice made, but also if -1 is in index, we continue the story without making the choice.
func choice_made(story:InkStory,index:int):
    for c in %choices.get_children():
        c.queue_free()
    first_button = true
    if index != -1:
        story.choose(index)
    # Continues the story.
    next.emit()

How To Include in YOUR Rust project

To Cargo.toml, add the dependancy:

gdrs_ink = { git = "https://gitlab.com/greenfox/gdrs-ink" }

In lib.rs, add:

pub use gdrs_ink;

Last, make sure you set the environment variable GDRUST_MAIN_EXTENSION to match your impl ExtensionLibrary for _____. This can be done through your build scripts, but another good way to do this, is to make a .cargo/config.toml and add this:

[env]
GDRUST_MAIN_EXTENSION = "YourExtensionLibrary"

Changelog for version 0.2.1

No changelog provided for this version.

Reviews

GDRS Ink has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.