Can I have a passage separate from my story that stores all my variables, which I can later use in the actual story?

0 votes
asked 4 days ago by warpfall (120 points)

1 Answer

0 votes
answered 4 days ago by Chapel (30,050 points)
What format and version?

Separate how? Existing outside the story's normal scope? Just simply not accessible to the player?

What do you mean by store? Store how? A list of variables set to specific values? User / play defined values? Static values? A list of initialized values? Just a list of variables names?

Use later for what? To reset variables? To initialize them? To set them to specific values based on the passage? Just to display?

The simple answer to your question is probably yes. But depending on your goals and your format, the actual answer will change pretty dramatically.
commented 4 days ago by warpfall (120 points)
Yeah, I mean separate as in the flow of the narrative never touches/comes to that passage.  I think what I'm trying to ask is that is there a way for me too have a place to store my variables to later use in my other passages. I am using variables like Player-Health and Player-Damage. Of course these variables will change according to what the player has equipped and factors like that. Also their health will be displayed so the place I store my variables needs to be open and accessible through out all my passages. I hope this makes sense.
commented 4 days ago by Chapel (30,050 points)
I'm still not sure what you mean. Story variables (i.e. $var) should be available to all passages across your story.

All story formats include syntax or macros for controlling the output of code and line breaks, if that's your issue. All story formats also include some way to display one passage in another passage so that the displayed passage's code can be run, and there are ways to combine this with the other methods of controlling your presentation to make this happen without yielding any output.

Harlowe and SugarCube also both have start-up / initialization passages for silently initializing variables. Something similar could conceivably be put together for Snowman and other formats.

Unfortunately, as you still haven't mentioned the story format and version of it that you're using, I can't really provide specific examples of any of this. I'm not sure I'm understanding you anyway, though.

Could you post examples of your code and describe what it's doing vs. what you want it to be doing? And please tell us which format and version you're using. You can find that information by clicking "change story format" in the little arrow menu near your story's title, if you aren't sure (in Twine 2).
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.
...