Skip to content

Problem with Story.ChoosePathString and choices that run out #581

Description

@gimblll

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.

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions