Howdy, Stranger!

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

(Harlowe) Help with setting variables to random occurances

edited October 2016 in Help! with 2.0
So in the game I've got going, I'm trying to give the character a generated name with random letters by using a series of (either:) macros. I want that name to be used in a later passage, so I'm trying to set it to the variable $name. Here's an abbreviated version of what I'm writing:
My name is (set: $name to "(either: "A", "B")(either: "c", "d")(either: "e", "f")")

Around it, I have bold, italics, and then passage to a different page, but I didn't think those things were relevant. The error message I'm getting is "missing ) after argument list", but I don't think I'm missing any parentheses. What am I doing wrong?

Thanks!

Comments

  • Try removing the quotes around the eithers, so:
    My name is (set: $name to (either: "A", "B")(either: "c", "d")(either: "e", "f"))
    
  • Try removing the quotes around the eithers, so:
    My name is (set: $name to (either: "A", "B")(either: "c", "d")(either: "e", "f"))
    

    I get the same error message.
  • edited October 2016
    Another note: I tried using
    (put: "(either: "A", "B")(either: "c", "d")(either: "e", "f")" into $name)
    
    (with and without the quotation marks around the (either: macros) and that didn't work, either. Is there some Javascript code I need to put in to make this work?

    Edit: after doing some trial and error, I've found that this works perfectly fine with only one of the (either:) macros, but as soon as there's two in there, things go haywire. Is there anything I can do to have more than one?

    Edit 2: I FIGURED IT OUT you just need +'s between the macros yay
  • Um, not to do with the question, but I just wanna point out; if the first letter is either A or B, surely the second letter should be a random vowel (I,O,U,E,A)? I dunno.
  • Deadshot wrote: »
    Um, not to do with the question, but I just wanna point out; if the first letter is either A or B, surely the second letter should be a random vowel (I,O,U,E,A)? I dunno.

    It was just an example. I'm not actually using those letters for the names.

    Also, for anyone who has this same question: I figured it out! All you have to do is add + between the macros. It will look something like this:
    (put: "(either: "A", "B")+(either: "c", "d")+(either: "e", "f")" into $name)
    
  • it seems like a better idea to let users choose their own names than settle for something weird like baf grb of course depending on what letters you choose, anyway if you change your mind here's the code to let users choose their own names
    (set: $name to (prompt: "What's your name?"))
    
  • (put: "(either: "A", "B")+(either: "c", "d")+(either: "e", "f")" into $name)
    
    Your example will not work for two reasons:

    1. It is trying to use double quotes to both delimit each String Parameter of the (either:) macros calls as well as delimit the overall String value being assigned to the $name variable, this is invalid and to fixed this you would need to either use two different quote types or escape the double quotes delimiting the String Parameter of the (either:) macros calls:
    (put: "(either: 'A', "B")+(either: "c", "d")+(either: "e", "f")" into $name)
    
    (put: '(either: "A", "B")+(either: "c", "d")+(either: "e", "f")' into $name)
    
    (put: "(either: \"A\", \"B\")+(either: \"c\", \"d\")+(either: \"e\", \"f\")" into $name)
    
    ... but even doing that will not give you the result you are looking for because...

    2. By making the overall value a String you are delaying the execution of the (either:) macros until the point you actually output the value of the $name variable in a passage, and that output will include the "+" characters.

    You were close with your solution, you just need to remove the overall String delimiters:
    (put: (either: "A", "B") + (either: "c", "d") + (either: "e", "f") into $name)
    
    (set: $name to (either: "A", "B") + (either: "c", "d") + (either: "e", "f"))
    
Sign In or Register to comment.