-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the bug
I continuously get a null reference exception in C# when I try to create a new Ink Story from some code I loaded. As I have found out, the runtimeStory variable is never actually initialized for some reason. Thusly, Initialize InitializeRuntimeStory() must not be called when I set the story text.
To Reproduce
Pass in the path of a valid Ink file. In my case it was "res://ink/core/main.ink".
using Godot;
using GodotInk;
using Ink;
using Ink.Runtime;
using System;
public partial class CustomSetup : Node
{
private InkStory Story;
private void LoadInkStory(string path)
{
var storyText = Godot.FileAccess.Open(path, Godot.FileAccess.ModeFlags.Read);
Compiler compiler = new Compiler(storyText.GetAsText(), new Compiler.Options
{
sourceFilename = path,
errorHandler = InkCompilerErrorHandler,
fileHandler = new FileHandler(
System.IO.Path.GetDirectoryName(path) ?? ProjectSettings.GlobalizePath(path)
),
});
String actualStoryContents = compiler.Compile().ToJson();
Story = InkStory.Create(actualStoryContents);
GD.Print(Story.CanContinue);
}
private class FileHandler : IFileHandler
{
private readonly string rootDir;
public FileHandler(string rootDir)
{
this.rootDir = rootDir;
}
public string ResolveInkFilename(string includeName)
{
var resolvedFile = System.IO.Path.Combine(rootDir, includeName);
return resolvedFile;
}
public string LoadInkFileContents(string fullFilename)
{
fullFilename = fullFilename.Replace(":\\", "://").Replace("\\", "/");
var text = Godot.FileAccess.Open(fullFilename, Godot.FileAccess.ModeFlags.Read).GetAsText();
return text;
}
}
}
Environment
- OS: Windows
- Godot version: 4.2.1-mono
- godot-ink version: 1.1.2
- ink version: 21?
Additional context
I'll expand on my example with a minimum viable project when prompted for one.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request