Howdy, Stranger!

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

Showing only certain passages if certain criteria is met

I'm having issues trying to put the code together for something. I'm using Harlowe on Twine 2.

How can I have passages that show only once, the first time you visit that passage? I want it so that the first time the passage is visited this whole part is shown.
You tread through the thick patches of of branches and vegetation. You stand still for a second on the damp ground and suddenly notice something squirming right next to your foot. It's an orange meter-long centipede (the legs longer though, like a spider with a red horn adorned on the head. The type of insect that makes your soul try to crawl out of you in any direction. You only have a split second to react!

What do you do?

Try to stand still and wait to see if it passes->B6 Wait
Quicly try to stomp on it before it attacks!->B6 Stomp
Step back and make a run for it!->B5 Jungle

And then after the first it's just a standard message?

Comments

  • You have to set a variable (I keep all those variables in my start page, so when the game starts they are all ready to do their work, but you can follow the advice at point 2 in this post: http://twinery.org/forum/discussion/5181/twine-2-harlow-how-can-i-reduce-repeated-code#latest) for the passage, and set it false.
    (set: $ExploredPassage to false)

    Then you have to put a link that could turn the variable on "true" when you visit the passage, but under a "if" condition

    (if: $ExploredPassage is false)[ (link: "NameofPassage")[(set: $ExploredPassage to true)
    You can write text here
    link to whatever you want
    ]]
    (else:)[Write here what you want, it's the Passage description you'll see from the second time. You could put other links or other conditions to be checked and so on]

    Pay attention to the numbers of square brackets to close to make the code "right": I spend a lot of time searching for the Lost Bracket! :)

    So the first time the variable is false and the game will display all the choices you want, the second time the variable will be true, and so the game will dispaly all the code that lies after the condition (else:)

    I hope the tip could help you.
  • Coincidentally, I uploaded a second sample story at the end of the above post, which does exactly that (i.e. displays text only first time into passage)
  • SixPix wrote: »
    (if: $ExploredPassage is false)[ (link: "NameofPassage")[(set: $ExploredPassage to true)
    You can write text here
    link to whatever you want
    ]]


    Thanks SixPix. I'm having trouble understanding the part with (link: "NameofPassage").
    I did as greyelf suggested in the other post and put a startup passage and put my variables there. I set the variable to zero in the first passage.
    I also put in the code as you said inside of the passage that I want to display a certain message the first time.

    Now I start the game and go to the passage and just get a blank as if it's not processing at...

    This is what I have on the Passage.

    (if: $ExploredB6 is false)[(link:"B6 Wait")[(set: $ExploredB6 to true)
    You tread through the thick patches of of branches and vegetation. You stand still for a second on the damp ground and suddenly notice something squirming right next to your foot. It's an orange meter-long centipede, only with legs like a spider and a red, black-tipped horn on it's "head". The type of monster that would make your soul want to run for it. You only have a split second to react!

    What do you do?

    Try to stand still and wait to see if it passes->B6 Wait
    Quicly try to stomp on it before it attacks!->B6 Stomp
    Step back and make a run for it!->B5 Jungle


    (else:)This is what would normally appear
    ]]

    I attached the debug view.

    I'm also not sure if I'm doing as greyelf mentioned right. The startup passage I named "Startup" and I put in the tag "Startup". I didn't set it as the starting point though because as I had understood Twine will do this automatically and read the code from startup but start the story in the other passage. Am I right with this?
  • The startup passage I named "Startup" and I put in the tag "Startup"
    Passage tags are case-sensitive, the startup tag needs to be all lower-case.

    The issue with your example is the placement of close square bracket of the (if:) macro's associated hook, you have the (else:) macro inside the (if:) macro's hook. It should be something like the following:
    (if: not $ExploredB6)[
    	(link:"B6 Wait")[
    		(set: $ExploredB6 to true)
    
    		... The text and the three markup links ...
    	]
    ]
    (else:)[
    	... This is what would normally appear ...
    ]
    
    notes:
    a. I replaced the $ExploredB6 is false with an equivalent not $ExploredB6
    b. I added indentation and line-breaks to make the example more readable and so you can clearly see the open and close square brackets of each associated hook.
  • Amazing...I finally got it! It was the whole Startup vs. startup thing. Thank you both!
Sign In or Register to comment.