ink icon indicating copy to clipboard operation
ink copied to clipboard

How to gather after a divert?

Open ben4d85 opened this issue 4 years ago • 1 comments

In Ink, how can I gather after a divert?

I am writing a quiz that is comprised of the following two ink files.

The problem is that I cannot work out how to get Ink to allow me to choose another round after completing the first one.

quiz-main.ink

INCLUDE quiz-rounds.ink

Welcome to the quiz!
-> ChooseRound

=== ChooseRound ===
Please choose a round!
* Round 1
    -> Round1
* Round 2
    -> Round2
* Round 3
    -> Round3
    
- Bye now. // The ink never flows here :(
-> END

quiz-rounds.ink

=== Round1===
Welcome to Round 1. Which do you prefer: Puppies or Kittens?
* Puppies
    ~correct()
    -> Won
* Kittens
    -> Lost

=== function correct() ===
{~Correct|Well done|Go you}!

=== Won ===
Well done, you completed this round!
-> ChooseRound // Ink cannot find this knot :(
// And if I remove the divert instead, it complains about the loose end

=== Lost ===
Wrong, try again next time!
-> ChooseRound // Ink cannot find this knot :(
// And if I remove the divert instead, it complains about the loose end

Of course the problem is that in quiz-rounds.ink, Ink does not know what ChooseRound refers to. I tried including quiz-main.ink into quiz-rounds.ink, but that of course leads to a circular dependency, which Ink does not like either.

Separating content across files seems like a pretty standard thing to want to do, so how can this be solved, please?

ben4d85 avatar Jun 07 '21 06:06 ben4d85

Does it works well when everything is in one file? It should work. When you are opening the quiz-main.ink, you should see a panel opening on the left with the file included. Switch file with that panel, do not open the file in another inky editor.

If you have an error, I think it may come from another part of the code, not here.

By the way, I don't think it's working like you want, as you will just run out of choice in the ChooseRound part when you will be finished. (transforming your - Bye now. in * []Bye now should be good) (this choice will only be available when there is no other choice.) Another way to achieve what you want should be to transform your simple divert to tunnels. You'll get into the flow right back, but you will need the loop mechanisms with the same modification.

(I don't have inky installed yet on my current machine so I can't test your code to know if everything is working well)

Selsynn avatar Jun 07 '21 15:06 Selsynn