You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an external function in an Ink script to evaluate a simple conditional check (e.g., checking if an integer variable is greater than a value), godot-ink throws an error during execution.
The error message suggests that the Ink runtime is attempting to pop too many objects from the evaluation stack, leading to a System.Exception: trying to pop too many objects.
Create an Ink script containing an external function that returns an integer.
Use this function to print the evaluation of a conditional statement inside a choice.
NB! Don't use it as a conditional for the choice visibility, but print its result within the choice's text.
Load and run the story in Godot using godot-ink.
Observe the crash with the error message.
Example Ink Script:
VAR money = 2
Once upon a time...
* There were {get_money() >= 2} two choices.
* There were four lines of content.
- They lived happily ever after.
-> END
=== function get_money()
~ return 12
EXTERNAL get_money()
Example C# Code
using Godot;
using GodotInk;
public partial class QuickStartGuide : VBoxContainer
{
[Export]
private InkStory story;
public override void _Ready()
{
story.BindExternalFunction("get_money", Callable.From(GetMoney));
ContinueStory();
}
private void ContinueStory()
{
foreach (Node child in GetChildren())
child.QueueFree();
Label content = new() { Text = story.ContinueMaximally() };
AddChild(content);
foreach (InkChoice choice in story.CurrentChoices)
{
Button button = new() { Text = choice.Text };
button.Pressed += delegate
{
story.ChooseChoiceIndex(choice.Index);
ContinueStory();
};
AddChild(button);
}
}
private int GetMoney()
{
return 5;
}
}
Expected
The conditional check {get_money() >= 2} should resolve properly within the text, allowing the game to continue execution.
Actual
Godot throws the following error when executing the script:
The issue does not occur when the external function is used normally (e.g., printing its value in text without a conditional).
It seems related to evaluating the function call inside an inline conditional check ({get_money() >= 2}).
Possibly an issue with how godot-ink handles inline evaluations of external function calls.
Workarounds include manually storing the function's return value in a variable before using it in a condition.
The text was updated successfully, but these errors were encountered:
I am not sure how to test that though... I can confirm that it doesn't happen in any of my Unity projects using different versions of the Unity Ink runtime.
This is a workaround within Ink to avoid the behaviour in Godot.
~ temp characters_money = get_money()
+ [<{characters_money >= 2}>Pay her two gold pieces.]
Describe the bug
When using an external function in an Ink script to evaluate a simple conditional check (e.g., checking if an integer variable is greater than a value),
godot-ink
throws an error during execution.The error message suggests that the Ink runtime is attempting to pop too many objects from the evaluation stack, leading to a
System.Exception: trying to pop too many objects.
To Reproduce
Example Ink Script:
Example C# Code
Expected
The conditional check {get_money() >= 2} should resolve properly within the text, allowing the game to continue execution.
Actual
Godot throws the following error when executing the script:
Environment
Additional context
The issue does not occur when the external function is used normally (e.g., printing its value in text without a conditional).
It seems related to evaluating the function call inside an inline conditional check ({get_money() >= 2}).
Possibly an issue with how godot-ink handles inline evaluations of external function calls.
Workarounds include manually storing the function's return value in a variable before using it in a condition.
The text was updated successfully, but these errors were encountered: