Indentation errors

Hi! I’ve been getting several error messages regarding indentation even though I can’t find anything wrong when looking at the code.
It seemingly happens at random places. As an example, here’s one I got just now:

RANDOMTEST FAILED: Error: prologuebackgrounds line 2340: increasing indent not allowed, expected 0 was 2

Here’s the place where I get the error:

I keep getting it at other places too, not just when random and quicktesting but when playtesting. Another example is here:

1 Like

Could I check what program you were using to edit the text files prior to this occuring?

I had a similar issue where I accidentally clicked the bold button on top of Windows Notepad when working on my text file. (Windows Notepad now has a text formatting toolbar.) I unbolded the text I accidentally bolded, but this still messed up the file anyway and caused the indent errors to appear.

(Disclaimer: I don’t know if my issue was the same as the one you have now.)
I remembered that I fixed this after three hours of trial and error by copying the text into an internet browser address bar to strip the formatting, then copying and pasting the text from the address bar to a new notepad file, and repairing the line breaks by hand. Then, I deleted the old notepad file and renamed the new notepad file to the name of the old one. I don’t know if your problem is the same, but if it is, this was my fix. You might want to try it on one section first, if we can ascertain that this was possibly due to notepad formatting.

1 Like

I use Notepad++. Sometimes I write in Word, but I always code in Notepad++. The strange thing is I’ve been doing it for ages without issue and now suddenly I’m getting indentation errors everywhere even though I code the same way as before :melting_face: sometimes it’s of course me mixing up spaces and tabs or making other mistakes, but since yesterday this just keeps happening even though I’ve checked that I only use tabs under choices and *if statements. I’m so confused.

I could try just putting it into a new file like you did, but it’s almost 200k words. So hmm. I feel a bit stuck. Thank you for sharing your method :heart:

1 Like

Try copying a small portion of the file which contains the indent error, put it in a new file, add an early *finish, and see if randomtest can get past it?

1 Like

Did you turn “show hidden symbols” on? That should help you see where the extra spaces are.

2 Likes

I think I’ve solved it! I went to View → Show Symbol → Show All Characters. Turns out there was some empty space in front of some tabs. Not sure how it got there, but I solved it like this:
Copy-pasted the empty space and then used ‘replace all’ but left ‘replace with’ empty.
Now I’m not getting the error anymore :raising_hands:

It could be that this error occurred because I’ve copy pasted all the text from twine and word? Just adding that in case anyone else has issue with this in the future.

2 Likes

This could happen because Word is a word processor. Basically, it adds hidden formatting code that you wouldn’t see. Definitely DON’T code in Word, Docs, and other word processors. As it will likely result in errors, when pasted into a text-editor like Notepad++. You can pull it off, but it’s generally not advised to do so.

But yeah, Notepad++ and IDEs are fine to use. Oh, and always have conscious to backup your files.

2 Likes

Ahh, I see! I don’t do the coding part in Word, I always code in Notepad++ and only use Word for writing. But maybe the copy pasting still causes issues? My other IF project is largely written and coded directly in Notepad++ and I haven’t had these issues happen with that one, so it probably has to do with the copy pasting I’ve done from Twine and Word :thinking:

Thanks for reminding me about backing up files. I try to do it after every writing/coding session but often forget to :weary_face:

Yes, this is most likely the reason.

If you find yourself in this situation again, or someone else does, try pasting using CTRL+SHIFT+V instead of plain CTRL+V. This is a shortcut for pasting only the unformatted text, and it strips away a lot of the hidden extra stuff that programs like MS Word add. Try is on the bolded text above, and you’ll see exactly how it works.

2 Likes

If you use a fully featured code editor, they usually have something like “convert spaces to tabs” and “convert tabs to spaces”, which will convert all mixed space-and-tabs into either one.

1 Like

Notepad++ does, in fact, do that too.

3 Likes

Thank you SO much for that. Definitely gonna keep that in mind for the future!

And @dozendietcokesaday and @LiliArch , I didn’t know Notepad++ had that feature but I’m going to look into that as well. Could be really helpful to avoid those empty spaces that ruin the indentations :slight_smile:

2 Likes