[Help] Struggling with If Statements and Boolean Operators

Twine Version: 2.3.7
Story Format: Harlowe 3.0

I’m trying to make a long series of (if:) statements for a generative text piece, but every one of my statements is giving the same error.

“I can only use ‘and’ to join booleans, not a ‘to’ or ‘into’ expression.”

All of the conditionals follow this format:
(if: ($theme is 1) and ($line1 is 1))[(str: $Walmart's 1st)]

I’m not sure what’s happening. I’m using an identical format in a test passage elsewhere and it works just fine. There is a little bit of setup, but I don’t think it does anything differently.


(link-reveal-goto: "Generate a Random Poem", "Poem")[(set: $line1 to (random: 1,10))(set:$line2 to (random: 11,20))(set: $line3 to (random: 21,30))(set: $theme1 to (random: 1,3))(set: $theme2 to (random: 1,3))(set: $theme3 to (random: 1,3))]

(link-reveal-goto: "test","test")[(set: $line1 to 1)(set: $theme to (random: 1,1))]

Can anyone help me fix this problem?

If I assume that you have previously assigned an Array value to the $Walmart variable…

(set: $Walmart to (a: 10, 20))

…then when I add following to the first Passage of test Harlowe based project…

(link-reveal-goto: "test", "test")[(set: $line1 to 1)(set: $theme to (random: 1,1))]

…and add a test Passage containing the following…

(if: ($theme is 1) and ($line1 is 1))[(str: $Walmart's 1st)]

…then when I select that link the test passage correctly displays 10 as I would expect.

1 Like

Thanks for your help, Greyelf! Everything’s working now.