+1 vote
by (370 points)
edited by

Hi, I'm working with Twine 2.1.3 and Harlowe 2.0.1 format. I was wondering if it is possible to put a different (set: $event to true) in if and else-if statements. Does this make sense? Is it possible to do what I just did? I thought this would save me a few passages if I could contain them in one passage.

Here is my code:

(set: $HinataConfession to false)\
(set: $HinataConfession1 to false)\
(set: $HinataConfession2 to false)\
(set: $HinataConfession3 to false)\
This is the first passage.

[[Passage 2]]

 

(set: $HinataConfession to true)\
This is the second passage.

[[Passage 3]]

 

(if: $HinataConfession is true)[(set: $HinataConfession1 to true)
So this is the first event.

[[Go back|Passage 2]]]\
\
\(else-if: $HinataConfession1 is true)[(set: $HinataConfession2 to true)
So this is the second event.

[[Go back|Passage 2]]]\
\
\(else-if: $HinataConfession2 is true)[(set: $HinataConfession3 to true)
So this is the third event.

[[Go back|Passage 2]]]\
\
\(else-if: $HinataConfession3 is true)[(set: $HinataConfession4 to true)
So this is the fourth event.

[[Go back|Passage 2]]]\
\
(else:)[So this is the last event.]

 

1 Answer

0 votes
by (159k points)
(if: $HinataConfession is true)[.....]

The first condition statement in Passage 3 will always evaluate to true because you set the $HinataConfession variable to true each time you transition to the Passage 2 passage. A better way to track the progress of a series of related events is to use a number to indicate which stage of the event series you are currently up to, and to increment that number to obtain the next stage.

1. Initialise your story variables within a startup tagged special passage.

(set: $HinataConfession to 0)

2. The First passage.

This is the first passage.

[[Next->Second]]

3. The Second passage.

This is the second passage.

[[Next->Hinata Confession]]

4. The Hinata Confession passage.

(set: $HinataConfession to it + 1)\
(if: $HinataConfession is 1)[\
So this is the first event.

[[Go back|Second]]]\
\
(else-if: $HinataConfession is 2)[\
So this is the second event.

[[Go back|Second]]]\
\
(else-if: $HinataConfession is 3)[\
So this is the third event.

[[Go back|Second]]]\
\
(else-if: $HinataConfession is 4)[\
So this is the fourth event.

[[Go back|Second]]]\
\
(else:)[So this is the last event.]

NOTE: Do the following to test if a variable's value is equal to either true or false.

(set: $var to true)
(if: $var)[Var is true.]

(set: $var to false)
(if: not $var)[Var is false.]

 

by (370 points)
Sorry for the late reply, but thank you so much for solving it!
...