Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Getting more than one link to work with an if/else statement

Looked around a fair deal, and I haven't noticed that anyone else has talked about this yet.

In my current story, I have a lot of interconnecting passages that the player may or may not have explored, and I want the links to each area to reflect that. For example, from passage 1, there are links to 2, 3, and 4, where 2 and 3 don't necessarily progress the story, but also give you two new options to go forward, 5 and 6, respectively. Going through either 4, 5, or 6 would have the player move forward into new experiences. So

> 2 -> 5
/ ^ \
/ | v
1-> 4
\ | ^
\ v /
> 3 -> 6

The problem I'm having is with coding the links between 2 and 3, so that if you've visited 3 already, instead of displaying the link to 3 again, 2 will instead direct you to 6, and vice versa with 2 and 5.

I've tried using

(if: (history:) contains "3")[(link: [6])]
(elseif: not (history:) contains "3")[(link: [3])]

and alternately

(if: (history:) contains "3")[(link: [6])]
(else:)[(link: [3])]

as well as using $variables instead of (history:)

(if: $3 is true)[(link: [6])]
(else:/elseif:)[(link: [3])]

or combination (if:) statements

(if: $3 is true)[(link: [6])]
(if: $3 is false)[(link: [3])]

No matter what I've tried, however, when I go to test the passages, I see errors like "Unexpected Identifier (link: [3])", or no links display at all. I know I could do this in SugarCube with the simple code

<<if visited ("3")>>
6
<<else>>
3
<<endif>>

so it it's frustrating that it's so much harder in Harlowe. I'm still new to using Twine in general, but it seems like Harlowe has a lot more functions that would be useful for game making, and I'd really like to learn more of it instead of just using SugarCube because it happens to be more convenient at the moment.

Any help or insights would be appreciated. Thanks.

Comments

  • Please use the C button to wrap your code examples in a code tag, it makes them easier to read/find.
    Rahdiyan wrote: »
    (if: (history:) contains "3")[(link: [6])]
    (else:)[(link: [3])]
    This example is almost correct except for two small issues:

    1. The syntax of the (link:) macro's parameter.

    If you look at the example included in the (link:) macro's documentation you will see that the Link Text parameter is wrapped in quotes not square brackets.

    2. You don't need to use the (link:) macro.

    You could use a standard markup link like the following example does:
    (if: (history:) contains "3")[ [[6]]]
    (else:)[ [[3]]]
    
    warning: Currently due to a bug that mishandles a sequence of three open square bracket you need to place a space character between the open square bracket of the (if:) macro's associated hook and the double open square brackets of the markup link.
  • Thank you!
Sign In or Register to comment.