0 votes
by (350 points)
edited by
This is going to make me cry...

I don't know how to make this happen, so I'll just describe this here and hope someone knows how:

I want one branch to be Touch-Averse and the other to be Not Touch-Averse-- I'm writing a romance with branching paths and I want the narrative to be able to switch over to the Touch-Averse or Not Touch-Averse, depending on what someone chooses to say at one point.

How do I create one of those if- then types of statements where the game will remember and go to the correct passages when it comes time for those scenes?

For that matter, how do I make it so I can put a choice in later for someone to say 'I'm not Touch Averse Anymore' so they can switch it off and have it work?

EDIT: Okay I finally got it to kind of work. Thank you everyone.

2 Answers

0 votes
by (8.9k points)

First you need to set a variable.  In this example, the player clicks a link to set $touchAverse to either true or false.

"Do you like to be touched?" asks the imp.

[[No.|nextPassage][$touchAverse to true]]
[[Yes.|nextPassage][$touchAverse to false]]

Then, in later passages, you use if statements to check the value of $touchAverse.

<<if $touchAverse == false>>\
The imp jumps into your arms and hugs you.
<<else>>\
The imp gives you a grin and a thumbs up.
<</if>>\

To change paths, simply give the player the opportunity to change the value of $touchAverse in a link.

<<if $touchAverse == true>>\
[[I don't mind if you touch me now.|nextPassage][$touchAverse to false]]
<<else>>\
[[Could you stop touching me for a while?|nextPassage][$touchAverse to true]]
<</if>>

 

by (159k points)

NOTE: You shouldn't be using comparison operators like == or is to check if a Boolean variable is equal to true or false. The correct syntax to do that is...

<<set $variable to true>>
<<if $variable>>The variable is equal to true.<</if>>

<<set $variable to false>>
<<if not $variable>>The variable is equal to false.<</if>>


INFO: The reason for this is because the <<if>> macro first evaluates the supplied expression to determine it's Boolean end-result, and then checks if that end-result is equal to true or false.

In the case of a Boolean variable it is already equal to either true or false so there is no need to preform the "evaluation of the supplied expression" step, so that step is skipped thus making the overall process quicker. But if you use a comparison operator with the Boolean variable you are forcing that "evaluation of the supplied expression" step to occur thus making the overall process slower than it needs to be.

by (8.9k points)

Thanks, I didn't know that.  smiley

+2 votes
by (159k points)

1. You could use a Boolean story variable to track which branch was selected like so:

Initialise the story variable to a default value within your StoryInit special passage. I will default it to being true.

<<set $isTouchAverse to true>>

2. You can then use two Links w/ Setters to allow the Reader to select what they want to say, which in turn will change the story variable to the correct value to indicate the relevant branch.

[[I am a Touch Averse type of person|Next Passage][$isTouchAverse to true]]

[[I am not a Touch Averse type of person|Next Passage][$isTouchAverse to false]]

3. You can use an <<if>> macro and the related <<else>> macro to control what text gets displayed within a passage...

/% Test if $isTouchAverse is equal to true. %/
<<if $isTouchAverse>>
	\You are a Touch Averse type of person.
\<<else>>
	\You are not a Touch Averse type of person.
\<</if>>

OR

/% Test if $isTouchAverse is equal to false. %/
<<if not $isTouchAverse>>
	\You are not a Touch Averse type of person.
\<<else>>
	\You are a Touch Averse type of person.
\<</if>>

,,, and you can do the same when determining which link to show...

/% Test if $isTouchAverse is equal to true. %/
<<if $isTouchAverse>>
	\[[Continue|The Touch Averse Related Passage]]
\<<else>>
	\[[Continue|The Not Touch Averse Related Passage]]
\<</if>>

OR

/% Test if $isTouchAverse is equal to false. %/
<<if not $isTouchAverse>>
	\[[Continue|The Not Touch Averse Related Passage]]
\<<else>>
	\[[Continue|The Touch Averse Related Passage]]
\<</if>>

4 You can use a Link w/ Setter to toggle the story variable between true & false like so...

[[Toggle the current state of the Touch Averse story variable|Next Passage][$isTouchAverse to not $isTouchAverse]]

... and you can do the same with a <<link>> macro..

<<link "Toggle the current state of the Touch Averse story variable">>
	<<set $isTouchAverse to not $isTouchAverse>>
<</link>>

 

by (350 points)
I found a way to make yours work, I think, but it was difficult, especially not knowing how to use whatever a Storyinit is.

So thanks.
...