As I build up my inventory system and other "reference" data my StoryInit file is getting unwieldly large, is there a way to have it source from multiple files so I can split things up for better organization (and it'd be really nice if it also helped with narrowing down errors, but I accept that might be a pipe dream).
There's also the possibility I am doing things very wrong and there's some other preferred way to include data that will be used throughout the story other than the StoryInit file.
On a similar note - can I split up the Javascript file? It, too is beginning to get excessively large.
Comments
Other than that, what I do is: I Store only the relevant variables in StoryInit that are displayed in my first passage (submenus, UI bars and the passage) and then I start to move the variables (primitives as well as objects) to different passages.
Say I have a HouseEntrance passage: I setup the variables here that have something to do with the house. The name, the containers inside the house, rewards, items, characters, etc. Now, these things are only relevant if the the player has reached the house otherwise this passage never triggers and the variables will not be set.
If you have and intro to your story you could split up your variables nicely.
Other things I like to do to organize my story better, is to have multiple passages that only contain widgets. For instance I have a widget for InventoryWidgets, QuestWidgets, NPCWidgets, CombatWidgets, etc.
About splitting JS, no idea. I tend to copy and paste the whole thing into Notepad++ and do the editing there. Especially for CSS, which has horrible syntax highlighting for the Dark Theme, that dark purple is nasty and hard to see.
When asking a question you also need to also state the version of Story Format you are using, as answers can be different for each one.
If when you say file you actually mean passage then you can use the <<display>> macro (replaced by the <<include>> macro in v2.15.0) to insert the contents of child initialisation passages into a parent StoryInit special passage.
The following three passage example shows one way to spread initialisation across multiple passages, the example is written in Twee Notation.
re: @Disane's comment about spreading the initialisation of the story variables across the passages of your story so that it occurs closer to were the variables are first used.
Although you can do that I personally would not recommend doing so because it results in you needing to remember where you initialise a particular variable if you need to change its default value at a later point or can't remember of a variable name is spelt, where as if all variables are initialised in StoryInit there is only one place to look. (or related locations if using the technique shown in the example)
Well, it would be nice to have type assitants like a suggestion list (an Inteli-sense kind of thing implemented in the Twine editor, also syntax highlight for the Story script would be nice too). Maybe some time down the line
Well, I tend to copy every script that describes a passage into one text file and leave comments at the begining and end so I can see where the passage starts and ends. This way Notepad++ has "full code coverage" over the whole Story, even JS and CSS and this way it can suggest the correctly spelled variable names to me.
I guess this could be nicely combined with the things you said above. I really appreciate the suggestion. It seems to be a better solution than what I described. Then again, I'm new here, but I learn fast and initiating a conversation about these things is always a good start.
Does the example you presented work in Sugarcube 2? (SC 2.14 and 2.15?)
I got a bit confused about the <<display>> and <<include>> macros... you mentioned there. Are they necessary? Eventhough you refer to :: Start and :: InventoryInit when you set your variables?
I'll definitely try this out!
What you doing is basically re-inventing Twee Notation, which I used in my previous three passage example.
Yes. (although you could of just tested that yourself *smile*)
Based on this statement/question I am guessing you missed the part where I said the previous example contained three passages and that I was using Twee Notation (which I supplied a link to for those unaware what that is).
eg. The three passages in the example are named Start, StoryInit, and InventoryInit; and the lines directly below the decoration of each passage is the content of that passage.
a. Importing the Twee source file and creating a project from it
b. Including the content of a Twee source file in an existing Story Project via the StoryIncludes special passage.
You can also build/compile Twine Story HTML files using command line tools as explained in the Using external IDE? thread.
That works great!, Thanks!