Howdy, Stranger!

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

Is it still possible to set variables with setter-links? (Harlowe)

edited May 2015 in Help! with 2.0
At the beginning of my game, I want to present the player with a selection of different "perks" (effectively, setting a variable to "yes" to allow players to bypass certain skill checks later in the game). One way to do this would be to create different unique pages for each link, where the variable is set at the top of the page or whatever. But for organizational purposes / general tidiness, I'd rather have all links link to the same single page, while the link itself takes care of setting the variable. I found a guide on the Twine Wiki, but I don't think the information applies to the most recent version of Twine / Harlowe.

For something like an example of how it apparently used to work:

* I want Perk Selected][$perk1 = yes
* I want Perk Selected][$perk2 = yes

Comments

  • Near the top of Harlowe's documentation there is a section titled "Syntax comparison to Twine 1" which contains an image showing the equivalent Harlowe code for things done in Twine 1.

    It states that the Harlowe equivalent of a setter link is something like the following:
    (link: "Link Text")[(set: $variable to "value")(goto: "Passage Title")]
    

    So your examples would be as follows:
    * I want (link: "Perk 1")[(set: $perk1 to "yes")(goto: "Perk Selected")]
    * I want (link: "Perk 2")[(set: $perk2 to "yes")(goto: "Perk Selected")]
    

    Don't forget to assign default values to your variables somewhere before the above code or your unselected perk variable will equal zero instead of "no":
    (set: $perk1 to "no")
    (set: $perk2 to "no")
    
  • @greyelf I reckon that did it! I don't know why I never thought to expand that image at the top of the Harlowe guide (I just kept Ctrl+F'ing for various terms that weren't written in the rest of the guide), but it has answers to a bunch of other questions too as it turns out.

    Thank you kindly!
Sign In or Register to comment.