Im a new user, background mostly in OOP developement. So i think too much how to optimize it instead of making it just work.
Everything here is just wierd for me.
However, i love this stuff. Makes my life easier and gives time and efforts for the important thing, story telling.
Im used to set up a init file, where i declare all variables and so. Now im bit confused. What is the best way to initialise all necessary variables etc. in this case?
External file, or add them to part of first scene of story?
If you’re using harlowe, you make an init passage (the equivalent of an init file) and tag it with “startup”, and it will be run once upon initialization. You can have multiple passages tagged startup, and they will be run in alphabetical order.
There are different story formats within Twine, so the answer depends on what story format you’re using.
Harlowe is, unfortunately, the default story format. However, I’d strongly recommend using the SugarCube story format instead. If you want to know the specifics of why, see the Reddit thread “2020, which do you prefer more - Harlowe vs Sugarcube?”.
If you’re using SugarCube you’d normally initialize variables within the StoryInit special passage. However, you can also do some initialization within the JavaScript section, any “widget” tagged passages, or when triggered by the :storyready event. See the “Refreshing and Restarting” section of the SugarCube documentation for details.
That said, I’d strongly urge you to use temporary variables (the ones that start with an “_”) whenever possible, and only use story variables (the ones that start with a “$”) as needed, and <<unset>> any story variables when you’re done with them. The reason why is that, unlike temporary variables, story variables are stored in the game’s history, and that bloating up the game’s history slows down saves, loads, and passage transitions. Thus, for optimal gameplay speeds, it’s best to minimize the use of story variables as much as possible.
I use datamaps, since i store characters in them. Characters haves properties and using datamaps allowed me to create a single template page where i can show information about character no matter which one it is.
Yeah, looks cool to me. Shame i have allready written so much, i dont want to restart anymore. But i will definately remember your advices for next project.