I'm testing out code to see if once the player enters this passage I can send the player to a random passage without their choosing. I'm using Harlowe and below is the code I'm trying to use. My problem is that the only passage the code chooses is the Random4 passage. I want their to be a equal chance (in this case 25%) for each of the four passages to be selected.
(set: $random to (random: 1,4))
(if: $random = 1)[(goto:"Random1")]
(if: $random = 2)[(goto:"Random2")]
(if: $random = 3)[(goto:"Random3")]
(if: $random = 4)[(goto:"Random4")]
Comments
This is the code that now effectively works in my passage.
Because you can't mark one of your own comments as an Answer, could you mark this comment instead so that this thread no longer appears within the Unanswered category.
What if I want the player to choose a random passage more than on time on my game?
So, the next time the player chooses a random passage, I want to remove from the pool of passages that one which was previously selected.
Is that possible?
To do this you would need to:
1. Initialise the list of passage names.
This must be done before the first random selection. I would suggest doing the initialisation within your story's startup tagged passage.
2. Randomly select a passage name from list and go to that passage. ... the above code does the following:
a. Checks that there are still passage names within the list.
b. Random determine the index of list item that will be used.
c. Get the name of the passage from the list
d. Remove that passage name from the list.
e. Go to the passage.
3. Use the code in point 2 each time you want to randomly go to a passage from the list.
4. You can either add new items to the list or replace the list with a different one at any time.