Howdy, Stranger!

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

Diverging a passage based on previous passage's choice

I'm trying to make a story where random encounters can happen when walking from one room to another. Let's say we've got a bedroom, and from this bedroom you can walk to the kitchen and living room. The bedroom would link to both of these rooms since you want to be able to choose to go there. Yet after clicking the link I'd want to end up in a "hallway" passage. If the random event happens, the hallway passage will deal with it, if not I'd want to link from the hallway to the room you originally intended to visit.

Is there a way for me to link to a passage and pass the name of another passage to it so that I can link to that passage properly later?

Comments

  • You can use a variable to track the name of the target Passage you want to end up in. So the Bedroom passage would look something like:
    You are in the Bedroom
    
    (link: "Kitchen")[(set: $next to "Kitchen")(goto: "Hallway")]
    (link: "Living Room")[(set: $next to "Living Room")(goto: "Hallway")]
    
    The Hallway passage can be implemented in a couple of way:

    1. The passage is always shown to the Reader, only the event is random:
    You are in the Hallway
    
    (if: (random: 1, 3) is 1)[Random event happened!]
    
    (link: "Continue to $next")[(goto: $next)]
    

    2. The Hallway passage is only seen if the Random Event happens:
    (if: (random: 1, 3) > 1)[(goto: $next)]
    You are in the Hallway
    
    A random event happened!
    
    (link: "Continue to $next")[(goto: $next)]
    
    note: there is a small problem with method 2, the Hallway passage is added to the Reader's History which means that if the Reader uses the Undo button when they arrive in the target passage they will end up in the Hallway passage even if the Random Event did not happen for them.
  • Thanks, that's exactly what I needed! I think I'll go with method 2 since I wanted to discourage the use of the back and forward buttons anyway. :)
  • I went with method 1 after all. Not because of the history thing, but because the hallway passage actually shows up for a fraction of a second and this isn't very appealing visually.
Sign In or Register to comment.