If statements for options that has value

hello, I’m new to both twinery and coding.
I was trying to write down a visual novel that I’m working on that basically has different points in each options. Simply put, the premise is like this :

each options will either be a good option or a bad option.
if the player choose more good option than bad, then the player will be lead to a good path passage.
the same goes the otherway around, if the player choose more bad option than good, then the player will be lead to a bad path passage.
if the good option = bad option than it would lead the player to another different path passage.

this is the current code I’m writting (note : red heart points = good option, black heart = bad) =

(set: $RedHeartpoints to 0)
(set: $BlackHeartpoints to 0)

choose wisely :
[[yes|option 2]] 
[[no|option 2]]

(if: $history contains "yes")[ (set: $RedHeartpoints to $RedHeartpoints+10) ]
(elseif: $history contains "no")[ (set: $BlackHeartpoints to $BlackHeartpoints+10) ]

haha I understand this is badly written, but it is my first time doing this, I’m still trying to figure things out.
But I don’t know how to search solution for this specific issue I’m having, so I’m hoping someone could help me out, thank you!

past me, this is your future self who found the solution right after you fricking posted the question.

The problem lies in you using the command “if/else-if” and keep searching in that area when actually you’re supposed to use another command lmao.
I copied from a twinery org post

result :
First Passage

(set: $RedHearts to 0)
(set: $BlackHearts to 0)
choose 
|yes>[yes]  
[no]<no|

{
(click: ?yes)[
	(set: $RedHearts to it + 10)
	(goto: "two")
]
(click: ?no)[
	(set: $BlackHearts to it + 10)
	(goto: "two")
]
}

the rest of the passages use the same code
then on the last passage I set the “go to” to a branch passage. There I input these codes to immediately lead the player to the endings based on their choices

(if: $RedHearts > $BlackHearts)[ (goto: "Red Hearts ending") ]
(else-if: $RedHearts < $BlackHearts)[ (goto: "Black Hearts ending") ]
(else:)[ (goto: "Neutral ending") ]

that’s it.

1 Like

@loqqi
Due to how the “click” family of macros are implemented it is generally advised to use one of the “link” family of macros instead whenever possible.

So ideally your first example should be…

(set: $RedHearts to 0)
(set: $BlackHearts to 0)
choose
(link-reveal-goto: "yes", "two")[
	(set: $RedHearts to it + 10)
]
(link-reveal-goto: "no", "two")[
	(set: $BlackHearts to it + 10)
]

…which uses the (link-reveal-goto:) macro to create what’s commonly called a “Link with Setter”.

1 Like