On a modern computer laptop, where 8M is the starting point, there really is no need for that level of space-saving sophistication. I did consider mentioning it, but then I thought, "Nah, who would do that these days unless programming right on the metal?"
Huh, I guess my answer "No one would!" was wrong.
Well, you have to keep in mind that the
You must be registered to see the links
on non-Firefox browsers shares the same 10 MB (or 5 MB on mobile) across
all local files (i.e. all HTML files on your computer). So, even if your game's saves aren't taking up much space in
localStorage, other games' data could be. (Firefox does a better job of this, where each local file gets its own 10 MB chunk of
localStorage based on filename and file path.)
That's why I wrote my
You must be registered to see the links
HTML page, which you can download and use to help manage
localStorage for HTML games that you've set up on your computer. Also, if you need to work with
localStorage or saving and loading files, then you might want to import it into the Twine editor and take a look at the code it uses.
Additionally, keep in mind that, if you have SugarCube tracking up to 100 entries in the game's history (you can change this by adjusting the
You must be registered to see the links
), then that means that you could have up to 100 versions of some data in the game history. Even if it's something that only takes up about 100 bytes of data, when you multiply that by 100 entries in the game's history, it's now about 10,000 bytes, or just shy of 10 kB for that one tiny bit of data. Technically it probably takes up less space than that in
localStorage, because the story variable's name is also stored (which adds more data), SugarCube tracks only the changes in the history (which reduces the size of the data), and then
You must be registered to see the links
that history data (which reduces the size of the data even further), but that's still more data to compress, thus more slowdown for saves, loads, and passage transitions.
All of that is why it's a good idea to minimize history usage however you can.
My one caveat would be to hide the bitwise coding behind method calls. So something like IsQuestDone(questIndex) would return true or false for anyone asking, and the code making the call would never be exposed to the bitwise stuff happening inside.
Yeah, if you take a look at the "
You must be registered to see the links
" I linked to, it pretty much does that, though in a more generic form.
As a fun aside, I wrote code that actually did the bitwise stuff in pure assembly to make sure it was small and it was fast, since it was being called a so often -- lots of bitwise left and right shifts.
I did that as well. I studied
You must be registered to see the links
in college (only person in my class to finish the final exam before time ran out too, despite renaming most of the variables and then the teacher demanding that I rename them back) and I've since used
You must be registered to see the links
to optimize code on Windows several times.
Fun stuff!