ephread / inkgd

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

External function is called twice after divert #27

Closed you-win closed 3 years ago

you-win commented 3 years ago

Describe the bug After diverting from a knot and calling an external function from the new knot

To Reproduce Example included below. When diverting to quest_completed from from_quest_accepted_0, the function end_quest(quest_name) is called twice.

= from_quest_accepted_0
~ current_speaker = "LEFT"
"..."

* {check_quest(quest_name)} "Yes" []
-> quest_completed
* {not check_quest(quest_name)}  "Yes" (lie) []
-> quest_completed_lie
* "Not yet" [] -> from_quest_accepted_1

=== quest_completed
~ current_speaker = "RIGHT"
{end_quest(quest_name)}
"Well ain't that something. I guess there are still good people out there."

* [next] -> dialogue_end

Expected behavior When diverting to a new knot, the end_quest function should only be called once.

The problem is fixed if the choice is structured like so:

* {check_quest(quest_name)} ["Yes"]
-> quest_completed

Note that the "Yes" has been moved inside the brackets.

It can also be fixed by removing the newline like so:

* {check_quest(quest_name)} ["Yes"] -> quest_completed

However, following this pattern for other diverts breaks the formatting since the newline is no longer present.

* "Yes" [] -> start_scenario

This causes "Yes" to be displayed on the same line as the divert.

Ink files Available upon request

Environment:

Additional context

you-win commented 3 years ago

So according to this piece of documentation, this is known behavior. Closing the issue.