Howdy, Stranger!

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

links that disappear once the passage is visited?

edited September 2015 in Help! with 2.0
hi! I'm new to this, so apologies if this is a simple question. I've been looking around for an answer for a while but I haven't found anything that I can make work.

I'm using Twine 2 with Harlowe.

So I have my character going on a trip, and he has several things he needs to do before he can do this. There's a passage where he's planning the trip, with links to other passages for each thing he needs to check off of his "to do list", so to speak.

Currently I have it formatted like this:
[[Return the reporter's call.]]
(if: $x is 2)[(print: "[[Pack.]]")]
(if: $y is 2)[(print: "[[Check the newspaper for anything.]]")]
(if: $z is 2)[(print: "[[Sleep.]]")]

Then each passage sets the variable so that after visiting the first link and going back, the second link will appear, and then the third, etc, until you have the option to sleep and progress to the next day.

This is okay, but what I would really prefer is that each time you go back, the previous link has disappeared and your only option is the new link. I've seen things about tagging and variables but I can't get it to work with links.

Thank you, I hope this makes sense! I'm happy to clarify if anything is unclear.

Comments

  • You could use a single variable to track how prepared the character is and then show once of the links based on that variable.

    note: Harlowe supports using a startup tagged passage to initialize (give default values to) your story's variables. If you don't have one yet then create a new passage, name whatever you like but I name mine Startup, and assign it a tag of startup.

    1. Place the following in your startup tagged passage:
    (set: $prepared to 1)
    
    2. Place the following in both of your Pack. and Check the newspaper for anything. passages:
    (set: $prepared to it + 1)
    
    3. Change the passage you want the links to appear in to:
    [[Return the reporter's call.]]
    {(if: $prepared is 1)[ [[Pack.]]]
    (else-if: $prepared is 2)[ [[Check the newspaper for anything.]]]
    (else:)[ [[Sleep.]]]}
    
    notes:
    a. I wrapped the above conditionals in curly braces {} to remove unwanted line-breaks.
    b. I also added a single space character before the conditional markup links, this is to get around a parsing bug in Harlowe. It has problems with three open square brackets [[[ appear together and is why you were using a (print:) macro to display those markup links.
  • This is great, thank you! So I can also include "Return the reporter's call" in the disappearing list by doing this:
    {(if: $prepared is 1)[ [[Return the reporter's call.]]]
    (else-if: $prepared is 2)[ [[Pack.]]
    (else-if: $prepared is 3)[ [[Check the newspaper for anything.]]]
    (else:)[ [[Sleep.]]]}
    

    and adding
    (set: $prepared to it + 1)
    

    to "Return the reporter's call" it seems like. Tested and it's working, which is awesome!

    What's the purpose of initializing the variable in the Startup passage versus putting it in the passage with the many links/to-do list? Is it strictly organizational?
  • What's the purpose of initializing the variable in the Startup passage versus putting it in the passage with the many links/to-do list?
    If you placed a (set: $prepared to 1) in the same passage as the conditional markup links then one of two things would happen:
    a. If the (set:) was before the conditional markup links then (if: $prepared is 1) would always be true.
    b. If the (set:) came after the conditional markup links then the (else:) would always be true.

    The only really important thing is that you remember to initialize a variable before using it in comparisons or outputs, where you do this is less important.

    There are any number of reasons to initialize your variables in a single place but the one I find most useful is memory. It is not uncommon for a story to end up having many variables and the Twine application itself will not help you remember how you named/spelt any of them, having a list of them in one place can help with this.

    Some other reasons also include:
    1. Organizational
    2. It helps if you need to assign a different default value when debugging your story if there is single known place to do the change.
    3. Currently Harlowe defaults uninitialized variables to zero but there is no way to know if this will change in the future, so by manually assigning a default value you future proof your story.
    4. Other people will look at your story source code for any number of reasons (interest, help debugging, cheating, etc..), having your variables listed in one place can help them.
  • Thank you for all your help! Makes total sense.
Sign In or Register to comment.