textadventures / squiffy

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

small quirk when using import and continue together #82

Open pigeonlips opened 4 years ago

pigeonlips commented 4 years ago

Wow - love your work. Having heaps of fun using it. A great tool.

Thought i'd point this out as i came across it. Its not a big deal, but it gets a bit confused when you use both import and continue. Heres what i think is happening. after compile, in the second file, it resolves to the same label for the data-section as the first file

<a class="squiffy-link link-section" data-section="_continue1" role="link" tabindex="0">but if i use continue</a>

heres an example ...

file1.squiffy

@import file2.squiffy

Wow - some text

+++lets go on
You'll see this all the time. Its great. Lets go to [[file2]]

file2.squiffy

[[file2]]:
Great import is fantastic. I can split my work into separate files ! 

+++but if i use continue 
i'll never see this text. and be stuck in a loop FOREVER ! 

anyway - not a big deal. Just thought i'd point it out. Can always use [[some other section]] as a workaround.

Thanks for the fantastic tool !

pigeonlips commented 4 years ago

just incase anyone is disparate to make both work, i hacked around it buy moving ....

https://github.com/textadventures/squiffy/blob/1ea68ad48a51980cc22ab4b5a6758ced700eaff1/compiler.js#L263

        this.processFileText = function(story, inputText, inputFilename, isFirst) {
            var inputLines = inputText.replace(/\r/g, '').split('\n');

            var compiler = this;
            var lineCount = 0;
            var autoSectionCount = 0;

to line 22 instead

    var marked = require('marked');
    var crypto = require('crypto');
    var autoSectionCount = 0;

As i didn't bother to read more than 8 lines of code, i wont be presumptuous and raise a pull request. I'll leave that for someone that knows what they are doing :grin:

pigeonlips commented 4 years ago

seems to work great. There are other ways to do this (could check to see if the var exists before declaring it and then leave it in the same spot). Anyhoo, have put up a pull to move it to the beginning of the file. Feel free to reject.

Again - thanks for the fantastic tool!