inkle / inkle/ink

Problem with Story.ChoosePathString and choices that run out

Open
#581 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.9k
Forks
540
PR merge metrics
No merged PRs in 30d

Description

Hello,

I have an issue with how Story.ChoosePathString works in cases when the knot has been run and all choices in it have been exhausted. I tried to put together a minimal example and a test script to show the behaviour. Not sure if this is something I don't understand or if it is a bug.

So first time TOPIC_A is run through, all works good and we choose the option there. Second time through, it still works (no options as we're all out). But then it gets stuck, and I can't get ChoosePathString to work again (even if using TOPIC_B). Also, if adding more choices to TOPIC_A there, as long as TOPIC_A has some choices remaining when running through it, it seems to work, but when it's all out is the time it gets stuck.

```csharp
private static void BugTest()
{
string test_story = @"

-> TOPIC_A
=== TOPIC_A

Topic A text
* [Reply A?]
Hello!
-
-> DONE

=== TOPIC_B
Topic B text
-> DONE
";

var compiler = new Ink.Compiler(test_story, new Compiler.Options { countAllVisits = true, fileHandler = null });
Story story = compiler.Compile();

story.Continue();
Debug.Log(story.currentText); // -> Topic A text

Debug.Assert(story.currentChoices.Count == 1);
Debug.Log(story.currentChoices[0].text); // -> Reply A
story.ChooseChoiceIndex(0);
story.Continue();
Debug.Log(story.currentText); // -> Hello!

// Story done
Debug.Assert(!story.canContinue);
Debug.Assert(story.currentChoices.Count == 0);

// Restart story
story.ChoosePathString("TOPIC_A");

story.Continue();
Debug.Log(story.currentText); // -> Topic A text

// Story done again as no choises and it jumps to end
Debug.Assert(!story.canContinue);
Debug.Assert(story.currentChoices.Count == 0);

// NOW IT IS STUCK, no ChoosePathString path string works, no matter if using TOPIC_A or TOPIC_B

// Restart story again
//story.state.ForceEnd(); // This doesn't help either
story.ChoosePathString("TOPIC_A");

story.Continue(); // FAILS! (the knot did not get restarted, nor will trying TOPIC_B help either)
//Debug.Log(story.currentText);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.