inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
4.14k stars 493 forks source link

Elements in nested stitches can have the same name #535

Open Path-Seeker opened 5 years ago

Path-Seeker commented 5 years ago

So, in order to visit gather of Stitch2, I have to write its path, however, the name is enough for gather in Stitch1. If I create an element with the name gather in the Knot's content, I'll receive an error.

-> Knot

=== Knot
    Knot's text
    -> gather -> Stitch2.gather -> END

    = Stitch1
        - (gather) Stitch1's gather text
        ->->

    = Stitch2
        - (gather) Stitch2's gather text
        ->->

Knot's text Stitch1's gather text Stitch2's gather text End of story

clembu commented 5 years ago

This is because the first stitch's content is accessible by default from the knot. When you have no knot-level content in a knot and divert to it, it auto-jumps to the first stitch in the knot. To be consistent with this behavior, names in the first stitch are aliased in the knot-level.

That said, @joningold : wouldn't it be sane to say that if there is content before the stitch, names shouldn't be unwrapped? Design-wise, I mean, regardless of technicity. Unless I'm wrong and this is not why this works like that.

Path-Seeker commented 5 years ago

@facelesspanda it looks like all names of the stitches are aliased in the knot-level, since I don't have any errors here:

-> Knot

=== Knot
    Knot's text
    -> gather -> gather2 -> END

    = Stitch1
        - (gather) Stitch1's gather text
        ->->

    = Stitch2
        - (gather2) Stitch2's gather text
        ->->

Knot's text Stitch1's gather text Stitch2's gather text

So the problem is more complicated. I cannot have the same name for the elements inside the knot's content ("gather" inside Knot and "gather" inside Stitch1), but I can for the stitches.