0 votes
by (210 points)
Hello guys I'm new, it's my first story (using sugarcube) and I'm having some trouble with nested if conditionals. I have this code:


<<if $privateTalkWithRobert == false>>
[[Conversar amb Robert Baratheon|Primer di&agrave;leg amb Robert][$privateTalkWithRobert = true, $RobertsTrust += 1]]

<<if $privateTalkWithTywin == false>>
[[Conversar amb Tywin Lannister.|Primer di&agrave;leg amb Tywin][$privateTalkWithTywin = true, $TywinsTrust += 1]]

<<if $privateTalkWithJaime == false>>
[[Conversar amb Jaime Lannister.|Primer di&agrave;leg amb Jaime][$privateTalkWithJaime = true, $JaimesTrust += 1]]

<<if $privateTalkWithCersei == false>>
[[Conversar amb Cersei Lannister.|Primer di&agrave;leg amb Cersei][$privateTalkWithCersei = true, $CerseisTrust += 1]]

<<if $privateTalkWithTyrion == false>>
[[Conversar amb Tyrion Lannister.|Primer di&agrave;leg amb Tyrion][$privateTalkWithTyrion = true, $TyrionsTrust += 1]]

<<if $privateTalkWithJoffrey == false>>
[[Conversar amb Joffrey Baratheon.|Primer di&agrave;leg amb Joffrey][$privateTalkWithJoffrey = true, $JoffreysTrust += 1]]



<<if $privateTalkWithTommen == false && privateTalkWithJaime && privateTalkWithTywin && privateTalkWithTyrion && $privateTalkWithRobert>>
[[Conversar amb Tommen Baratheon.|Primer di&agrave;leg amb Tommen][$privateTalkWithTommen = true, $TommensTrust += 1]]

<<elseif $privateTalkWithTommen == false>>
<span class="notYet">[[Conversar amb Tommen Baratheon.|Primer di&agrave;leg amb Tommen]]</span>



ERROR: Error: <<if>>: bad conditional expression in <<if>> clause: privateTalkWithJaime is not defined


But it IS defined in my JavaScript file! All the other links are visible and work fine. Only problem is Tommen's IF statements. :S

State.variables.privateTalkWithRobert = false;
State.variables.privateTalkWithTywin = false;
State.variables.privateTalkWithJaime = false; // Here
State.variables.privateTalkWithCersei = false;
State.variables.privateTalkWithTyrion = false;
State.variables.privateTalkWithJoffrey = false;
State.variables.privateTalkWithTommen = false;

What's going on here? Thanks in advance guys.

PD: If anyone noticed, yes these are characters from GOT lol.

1 Answer

+1 vote
by (68.6k points)
selected by
Best answer

You are attempting to access the nonexistent variable privateTalkWithJaime, rather than the correct $privateTalkWithJaime—note the missing story variable sigil.  Your <<if>> should look something like the following:

<<if not $privateTalkWithTommen && $privateTalkWithJaime && $privateTalkWithTywin && $privateTalkWithTyrion && $privateTalkWithRobert>>


by (210 points)
Ugh, I can't believe it was such a stupid mistake and didn't even see it! Thanks man!