Command line way to run Build::Proof and save to file?

Twine Version: Windows
Sugarcube, but I don’t think this matters

I recently lost some work with an errant cut/paste between sections. It wasn’t anything serious. Only a bit of it was actually irreplacable creative stuff, and fortunately I had a mnemonic to remember said creative stuff or at least get good enough replacements.

I should have done a Build::Proof and saved to text before all this as a precaution, because I knew the code was tricky and it wasn’t in source control.

All the same, I’d like to have been able to do something like Build::Proof from the command line and send it to a non-temporary HTML File, maybe even daily, to check differences and save when needed. (I do this for other projects, with an auto-commit.) The GUI is good enough, but is there a more regular automatable way?

This also brings up the question: what’s a good way to back up Twine files? I noticed Twine had an internal mechanism for backups, but somehow it did not save the information in question. (I used everything.exe and looked for HTML files created in the past 3 days, etc., that contained a key word.)

Source control doesn’t seem great since the HTML files are at least 550 KB. Though I may be assuming things here, and it’s okay, because only a small chunk in the middle changes.

I get the sense I might not be asking the best question, but … the TLDR is, what is a good process for keeping reasonable regular backups in Twine so that if I try tricky code changes, reversion isn’t too bad? Thanks!

Huh. So you found Documents/Twine/Backups, and it’s not there? I’ve never looked closely, but I thought it backed up every time you opened Twine. I believe Twine just autosaves the HTML to Documents/Twine/Stories, so any tools you might have to copy from there to make backups should be fine…? It doesn’t work great with version control since the HTML is sort of minified (so it’ll tend to run the last line of one passage into the first line of the next) but IIRC you can do it. The Twine editor just dumps the text of your passages into the HTML file as <tw-passagedata> elements.

You can also… not use the Twine editor, and just write in text files, where a line :: passage name marks the start of a new passage. Tweego will then compile to HTML, and VS Code with the Twee3 Language Tools plugin has syntax highlighting etc. And then you can save with regular version control…

3 Likes

Aha! Therein lies the problem. I just flat out left Twine open.

I should probably try some tests to verify that, yes, indeed, Twine does close.

It actually did seem to have backup files. Here I deleted the code at 6/19, but at 6/17, the code was there, or it should have been.

Thanks for the explanation of <tw-passagedata> which I’d seen a lot in the source, as well as the nod to Tweego. That probably looks more like my sort of thing. I found the Gui in the Twine editor tricky, but then, I’ve always preferred the command line.

So again thanks for answering my big question and then some!

Twine tries to make a backup every time you start the app, and every 20 minutes while you have it open. (source code)

Sorry you lost some work–it might be too late, but in case someone is in the same situation as you and is reading this later, you can also fish backups out of your temporary files. (Just realized that section header has a typo… kind of appropriate.)

3 Likes

Thanks so much for this! This is a great alternate solution. I in fact found the missing code. I don’t think you can blame yourself for this … as a relatively experienced programmer, I should’ve found these methods in part even after I realized I’d hosed my code. grep SpecialName c:\users\andrew\appdata\local\temp\*.html did the job. (Also, I didn’t know you could use environmental variables in the windows explorer gui! So thanks for that tip!)

For some reason I beat around the bush here but I didn’t nail things down. I saw the file://c:/users etc. in the address bar but I never thought to just go to the directory.

There were a bunch of red flashing lights that should’ve told me to look for ways to backup before making the changes I did. That’s something I should know as a programmer–I waited a couple days and tried a few things, but I should have asked earlier.

I did in fact search on twinery.org, but the thing was … the discussions bubbled to the top of the google search site:twinery.org backups, so the reference was hidden, and I never thought to go to the front page to look for the general reference manual! From other things I searched for and found, I got the manual, so I assumed this would happen for backups too. site:twinery.org/reference backups was the way to go – or, oh yeah, looking at twinery.org’s front page.

You see, I wound up with tunnel vision for my information learning Twine, because the community’s technical help about small twine tricks was so good!

Thanks for taking the time to help me out here. I felt kind of silly I didn’t see this myself–I’ve been able to recover lost information before (Notepad++ crash,) and while I didn’t totally panic after my errant cut/paste, I obviously wasn’t thinking as clearly as I could’ve.

(The funny thing is, there were some silly random town names I recreated that were actually better than the originals. So it all worked out very well.)

1 Like

You may also be interested in the Twine data format specs on GitHub: there’s one for the Twee 3 text format, one for the HTML output, and one for the way story formats work (which you likely don’t care about).

1 Like