0 votes
by (220 points)
My story size is already at 489kb and I am not even close to being done. I'm including 3 POVs in my story and many different choices. My file size isn't because of the word amount, it's because of how many passages + branches I have.

Is there a maximum file size, or will this branching and passage amount slow the game down?


Using Sugarcube 2.28 and Twine 2.2.1

1 Answer

0 votes
by (36.9k points)
edited by

The "maximum file size" is dependent on the hardware and software it runs on.  That said, the only Twine game I know of that started to hit those limits was almost 83 MB in size (primarily through embedded images, which isn't recommended for this very reason).  Since you're at about one 166th the size of that, I'd say you're probably safe. 

Also, the amount of branching or passages doesn't really slow the published game down, though it may slow down your ability to develop in Twine itself.  If you start hitting enough passages that editing in Twine becomes cumbersome, then it might be a good idea to switch to using Tweego[1] as a command line compiler of Twee source.  Tweego can turn existing Twine HTML into Twee source, and then you'd use an editor like Notepad++[2] or Visual Studio Code[3] to edit it, instead of Twine, and then Tweego could compile that Twee source back into HTML.

What can slow the game down would be having a large number of story variables (variables that start with "$") and a long game history.  This would become noticeable as slow transitions between passages, and slow loading and saving times.

The best things to do to avoid that is:

  1. use temporary variables when possible (variables that start with "_"),
  2. store data which gets set at initialization and never changes on the setup object[4] instead of using a story variable (e.g. in the "StoryInit" passage you might have "<<set setup.maxitems = 20>>", assuming that number never changes),
  3. try to avoid storing redundant or unnecessary data in story variables,
  4. and use the <<unset>> macro[5] on a story variable when you're done using it.

If you begin to run into problems, despite using those techniques, you could try reducing the history size by setting Config.history.maxStates [6] to a lower number than the default 100 in your JavaScript section.  Odds are that you won't need to do that though.  (Lowering this number reduces the number of times you can hit the "back" button to step backwards through your previous choices.)

Hope that helps!  :-)

[1] Tweego: http://www.motoslave.net/tweego/

[2] Notepad++: https://notepad-plus-plus.org/

[3] Visual Studio Code: https://code.visualstudio.com/

[4] setup object: http://www.motoslave.net/sugarcube/2/docs/#special-variable-setup

[5] <<unset>> macro: http://www.motoslave.net/sugarcube/2/docs/#macros-macro-unset

[6] Config.history.maxStates: http://www.motoslave.net/sugarcube/2/docs/#config-api-property-history-maxstates

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.