0 votes
by (140 points)
edited by
Hey!

I am new to Twine and I don't figure out how we can make a variable appears on a specific story moment. For exemple during my first chapter, I have a variable "x" that it is showed on the left section, and, I would like to make it replaced by a variable "y" during my second chapter...

Also at the end of my story I need to keep the value of my variable "x" like :  if "x" during my first chapter is > 30 you win the game...

I don't know if it is clear enough.. I don't know if it is possible or if i am just blind x)

Thank for everything

2 Answers

0 votes
by (158k points)
Are Chapters 1 & 2 in the same story Project, or are they in two different story projects?

If they are in the same story Project how do you currently track which Chaper the Reader is in?
by (140 points)
All the chapters (4) are on the same project. I don't track where the readers are as I have no idea how to do it and why it is important?
by (44.1k points)
By "track", he means, "How do you determine which chapter the reader is in?"
0 votes
by (23.6k points)

You can use a simple <<if>> statement to determine which variable will be shown. In your StoryInit passage you can set up a boolean variable:

<<set $chapTwo to false>>

Then show your variables like this:

<<if $chapTwo>>
$y
<<else>>
$x
<</if>>

At the point in the story you want $y to be shown instead of $x, simply switch $chapTwo to true - switch it back to false when you want $x to be shown once more.

by (140 points)
I am sorry I am not very familiar with Twine  (neither whith those kind of manipulations) yet, I wil try this! So if I have undersatand I create a new variable that is named as a part of my story?

I will just create a variable that contains another variable?
by (23.6k points)
You can name the variable however you want. Ideally you'll give it a name that makes it clear to you what you are using it for when you come back later on.

Also the variable does not contain another variable. It just either contains the value "true" or "false". The <<if>> statement will check that value and accordingly either show you x or your y variable. This way you can switch back and forth between showing x or y by setting the variable (which I named $chapTwo but you can name differently should you want) to true or false at the appropriate point in your story.
by (44.1k points)

Just to be clear here, normally you put a value into a variable, and then you display the value of that variable.  You don't "create a variable that contains another variable," but for what I think you're trying to describe, you could either change the value of a variable, copy the value of one variable into another variable, or display different variables depending on the value of another variable.

idling's example up top is the third of those three options.

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.
...