Howdy, Stranger!

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

Eithers within eithers?

I'm in the process of moving over a game I started making in Quest over to Twine (Twine is a lot easier to use for gamebooks I've found), and I've run into a problem. I'm trying to have either macros nested within other either macros, but it's not working when I do it. Here's an example of what I'm going for:
You entertain yourself by (either:"goofing around online","playing with your (either:"cat","dog","hamster")","watching TV") until you get tired and go to bed.
This was possible in Quest by nesting {random} statements, but Twine doesn't seem to like it. Am I just typing it wrong, or is this impossible in Twine at the moment? I can do something like this if I absolutely have to:
(set: $pet to (either:"cat","dog","hamster"))

You entertain yourself by (either:"goofing around online","playing with your $pet","watching TV") until you get tired and go to bed.
but I want to know if there's another option that doesn't involve a new variable before I take that route. Thank you!

Comments

  • Remember Twine isn't exclusively Harlowe. Some things may be more possible in other story formats. That said, yes, you're just typing it wrong.

    Try:

    You entertain yourself by (either:"goofing around online","playing with your cat", "playing with your dog", "playing with your hamsrer","watching TV")
    In your case there's no need for the nested statements.
  • I probably should have specified that the example is a simplified version of what I want to do. The actual message is much longer and has many more options in the nested either, so writing it over and over again would be really messy. Also, I would want the three options (in the case of the example, "goofing around online", "playing with $pet", and "watch TV") to all have the same probability of happening, so writing it out for each different pet would throw that off.

    And do you know a story format that it might be possible in? I'm not too familiar with the differences between them yet.
  • The simplest way to do what you're asking would be to first randomise a variable to 1, 2 or 3, then:

    If variable is 1, answer = goofing around
    If variable is 2, answer = playing
    If variable is 3, answer = TV

  • I might actually be able to help with this one. You can randomize it first and assign it to a tempVariable and then use the tempVariable in place of the other.

    Wouldn't that do it?
  • Alright, that's probably what I'm going to do. I tried using a variable and it works, so that's good. The sad part is I now have to go think up names for a bunch of new variables. Blehhh. :P Oh well, whatever it takes. Thanks for the speedy replies!

    Is there a special way of doing temporary variables in Twine that's different from regular variables? (I assume that means that the variable only exists in the passage it's declared in, although I may be wrong.)
  • If you are talking about garbage collection and memory leaks, I assume that since this is all browser-based, then no.

    I would say that if you just threw the word Temp on the front and never used it again, though.... we could call it disposed of.
  • On the first topic: you actually can nest (either:)s, according to my tests. The trick is to remember that you want each possibility to be a string, and that the (either:) macro is not supposed to be in the string.

    In other words, I moved the nested (either:) outside of the quotes and concatenated it with the prefix string.
    You entertain yourself by (either: "goofing around online", "playing with your " + (either: "cat", "dog", "hamster"), "watching TV") until you get tired and go to bed.
Sign In or Register to comment.