textadventures / squiffy

a tool for creating interactive fiction
MIT License
158 stars 37 forks source link

Weirdness when rotate example is restarted #39

Closed alexwarren closed 9 years ago

alexwarren commented 9 years ago

In http://docs.textadventures.co.uk/squiffy/rotate-sequence.html the examples work when the page is first loaded, but the order is then messed up after a restart.

arohman84 commented 9 years ago

already test it using this code from example template of squiffy and run it on localhost

Choose a number: {rotate:one:two:three}

+++OK...

Now {rotate result:four:five:six}

+++OK...

You chose {result}.

Now for a sequence: {sequence:one:two:three:four:five}.

+++And another...

Another sequence: {sequence seqresult:a:b:c:d:e:f:g}.

+++Finally...

You chose {seqresult}.

Here's a sequence that links to another section. {sequence:Ready...:Steady...:[[Go!]]}

[[Go!]]:

That's all folks!

there's no weirdness , both rotate and sequence goes fine when i restart using restart link

alexwarren commented 9 years ago

Maybe it only happens where there are multiple games embedded in a page. You can definitely still reproduce the issue on the documentation page I mentioned.

arohman84 commented 9 years ago

maybe it is, i'll check again maybe there's something i can do

ShadowKyogre commented 9 years ago

@caberg , @alexwarren: I can confirm this bug works with just one game when I ran the sample @caberg gave in the scratchpad.

That being said, why is the text attribute being munged in these lines: https://github.com/textadventures/squiffy/blob/master/squiffy.template.js#L523-L532

Rather than tracking which position the rotate/sequence is in?

I noticed is that it always starts off at the first element, but then progresses to the next element that was after the "current" element before the restart, so maybe there's a part of the code where squiffy's forgetting to forget the rotation position.

EDIT: Some additional testing with the example standalone indicates that the event misfires for every time the restart button if and only if squiffy's scroll mode is set to element, even if it's just a single story on a page. So maybe somehow, every time the restart button is clicked, it keeps accidentally adding the hook handling links multiple times.