Howdy, Stranger!

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

Alternate/random order text blocks in Harlowe (Twine 2.0.10)

I'm working on my character selection passage. I have three different characters that the player can choose. I'd like the list of possibilities appear in random order, so that different people, or the same person on replay, get a different character as the first listed choice. (I think people are more likely to pick the first option on the list, but I want all the options to have equal weight, as much as possible.)

Attempts so far:
1. Using (random:). I tried
(if: (random: 1,3) is 1)[You can choose to be Char1, Char2, or Char3!]

But this would require doing six different randoms to get all the possible list orders.

2. Using (shuffled:). I tried
(set: $choosechar to (a: "Char1","Char2","Char3")
(print: (shuffled: ...$choosechar)

This, while random, only prints one of the three choices.

Is there a better way to get a random list order?

Comments

  • I just tried your code in Harlowe 1.2.1 and Twine 2.0.10:
    (set: $choosechar to (a: "Char1","Char2","Char3")
    (print: (shuffled: ...$choosechar))
    

    and it printed the entire shuffled array, separated by commas. Does that not work?

    If you'd like a slightly prettier presentation, you can slip some Javascript into the print statement:
    (set: $choosechar to (shuffled: ...(a: "Char1","Char2","Char3")))
    (print: $choosechar.join(', '))
    

    I went ahead and shuffled the array before assigning it to $choosechar.
  • Thank you! Yes, the problem was the appearance--I couldn't figure out how to get rid of the commas. I've modified your javascript and it looks much better.
Sign In or Register to comment.