ephread / inkgd

Implementation of inkle's Ink in pure GDScript for Godot, with editor support.
MIT License
305 stars 33 forks source link

Attempting to create a story results in error spam due to null state #34

Open tlitookilakin opened 3 years ago

tlitookilakin commented 3 years ago

Describe the bug Attempting to create a new story via Story.new() repeatedly spams the error log with errors until the game is closed. The exact error differs every time but all of them stem from setgets being called while state is null

To Reproduce Create a new story while running inkgd on godot 3.3 stable

Expected behavior Creating a new story should work instead of crashing the game.

Ink files N/A

Environment:

Antokolos commented 3 years ago

Confirmed, I tried to use inkgd on Godot 3.3.3 stable, standard, and it refuses to work. In my case the error was in the following line https://github.com/ephread/inkgd/blob/3127d994106fa00e93430a9153f1b2fa3cc287ae/addons/inkgd/runtime/call_stack.gd#L397 The reason of error was self.current_thread being null

blawnode commented 2 years ago

I'm having near-identical issues. Is the inkgd project inactive?

ephread commented 2 years ago

Sorry for taking so long to reply folks, yeah, it's a bit inactive. I should probably update the README (and remove the trailing star in the ink library). I haven't had time to work on it in almost a year now.

I'll try to find some time to investigate soon.

videlanicolas commented 2 years ago

Is this happening only in Windows? I'm not seeing this issue in Linux (Debian 11).

Here's my example for reference: Godot: 3.3.4.stable.flathub Inkgd: 0.2.1

extends Control

const InkRuntime = preload("res://addons/inkgd/runtime.gd")
const Story = preload("res://addons/inkgd/runtime/story.gd")

var story : Story

func _ready():
    call_deferred("load_story")

func _input(event):
    if event.is_action_pressed("ui_accept"):
        continue_story()

func continue_story():
    while story.can_continue:
        var text = story.continue()
        print(text)
    if story.current_choices.size() > 0:
        print(story.current_choices)

func load_story():
    _add_runtime()
    _load_story("res://test.ink.json")

func _load_story(ink_story_path):
    var ink_story = File.new()
    ink_story.open(ink_story_path, File.READ)
    var content = ink_story.get_as_text()
    ink_story.close()

    self.story = Story.new(content)

func _exit_tree():
    call_deferred("_remove_runtime")

func _add_runtime():
    InkRuntime.init(get_tree().root)

func _remove_runtime():
    InkRuntime.deinit(get_tree().root)

Can you confirm you have runtime.gd as a singleton?

tlitookilakin commented 2 years ago

sorry for the late response- I do indeed have the singleton set up, and yes it has been occurring on windows. I even tested it with the provided example project and ran into the same issue. I haven't tried it with the latest release, so when I get a chance, I'll do that and let you know if it works.

Lertsenem commented 2 years ago

I have the same issue using Godot v3.4.2, and I can't figure it out.

It feels like the plugin refuses to create a story (fails happens once InkStory.new(json_story) is called, inside the InkPlayer), because _story (or sometimes _story._state) is null.

InkPlayer nodes created in editor still work, but I can't change their Stories dynamically (or create new InkPlayer node), which is pretty inconvenient. :/

ephread commented 2 years ago

@Lertsenem 😕

Which version of inkgd? Which OS? Does it happen after an export or while debugging?

Lertsenem commented 2 years ago

@ephread I'm on Linux (Ubuntu 20.04 LTS), I'm using the last inkgd stable version (0.4.5) cloned as a git submodule for my project, configured to use inklecate v1.0.0 (directly bundled with Mono).

It happens while debugging, I did not try to export my project yet.

Lertsenem commented 2 years ago

I can get the example project to run, and you are loading new Stories in it from code, so there must be something I'm doing wrong. But I can't figure out what.

Lertsenem commented 2 years ago

I managed to solve my issue !

I was trying a stupid method to create the ink_file like

var my_ink_file = InkResource.new()
my_ink_file.json = "res://my_story.ink"

replacing that with a simpler

var my_ink_file = load("res://my_story.ink")

makes everything works as expected.

Still no idea how this resulted in such a weird error though. :D