Howdy, Stranger!

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

Change passage randomly using twine links

Hello!

I would like to randomize which passages appear in the story.

I'm using Harlowe.

I tried this:

When you reached that house, you saw that (either: "[[the door was open|door]]" or "[[the window was open|window]]")

But it only ever shows the first of the two and never results in the second. I tried this:

When you reached that house, you saw that the [[(either: "door" or "window")]] was open

As suggested in another thread, but it only created one new link as well and it also only showed the first and not the second (and unlike the other method, did not create two boxes). I'm trying to keep this as simple as possible because I will be using it in a middle school.

Comments

  • The way I would do this, since you want the link text as well as the destination to change, is randomly set a variable at the start of the passage, then check the variable to see which link to display.
    (set: $open to (either: "door", "window"))

    When you reached that house, you saw that {
    (if: "door" is $open)[
    [[the door was open->door]]
    ]
    (else-if: "window" is $open)[
    [[the window was open->window]]
    ]}
  • That does work, thanks. I had just hoped not to have to introduce variables yet...
  • Ahhh! I looked back at your original post and I think I know what was going on.

    You have:
    When you reached that house, you saw that (either: "[[the door was open|door]]" or "[[the window was open|window]]")
    What you need is:
    When you reached that house, you saw that (either: "[[the door was open|door]]", "[[the window was open|window]]")
    The things you put in the "either" macro need to be comma-separated. I don't think "or" has been added as a joiner for it.
  • Oh! Thanks.
  • edited July 2015
    I'm having a similar problem with Twine, Harlowe. I want to randomize 3 different passages. The code I've used is: (display:(either:("Merry Meadow 2","Donkey","Grumpy gnome"))) - and its alone in its own passage (i.e. that's the only thing in this passage).

    I've clicked on it over 30 times and always get Grumpy gnome. I tried removing Grumpy Gnome and then always got Donkey. I tried removing both gnome and donkey, and then got Merry Meadow (at least I know I typed the links in correctly).

    Various different scenarios in various passages link you to this passage, which then randomly takes you to one of three outcomes. Or at least, such is the plan. I've tried clicking on a link to take me to this passage from other passages (to see if that will give me a different outcome instead of testing from this passage alone), but same result.

    Any ideas?
  • You have too many parenthesis. Try the following:
    (display: (either: "Merry Meadow 2", "Donkey", "Grumpy gnome"))
    
  • WOOHOO! It worked!! Thank you so much! :D

    This is my first experience in learning to make games and I'm absolutely loving it.

    Thank you again!
Sign In or Register to comment.