Newbie here, Need help with randomized paths

Twine Version: 2.5.1
Story Format: Harlowe 3.3.3

so im new to twine, and i need help with the randomizer.

so i have this cube, called RandomizerMain, and has this code:

(live: 3s)[
     (goto:(either: "1", "2","3","4","5"))
	(stop:)
]

and the code for 1,2,3,4, and 5 cubes have this:

(live: 3s)[
     (goto: "RandomizerMain")
	(stop:)
 ]

How do i make it so that when, for example, when 1 shows up, it never shows up again, and when everything has shown up, it goes to another cube called “AllGoneThrough”?

Any help would be Great!

1 Like

When using the (live:) macro try to call the (stop:) macro as soon as practical, to free up the expensive timer thread.
eg.

(live: 3s)[
	(stop:)
	(goto: "RandomizerMain")
]

What is being displayed within the Passages named 1 to 5?

I ask because you are only giving the end-user 3 seconds to view that content. And there may be a better way to achieve the same outcome without needing to pad the History System with 10 additional Moments.

To answer your question…

You can add the target Passage Names to an Array, randomly sort that Array, and then remove each Passage Name as it’s used from that Array so that it can’t be used twice.

The random list of target Passage Names needs to be initialised sometime before the RandomizerMain Passage is first visited, the example will do it in the passage visited just before hand but you may want to do the initiation within your project’s startup tagged Passage.

The following TWEE Notation based example likely includes one or more macros/features that you are not yet familiar with, and I strongly suggest you review each one’s documentation before hand so that you fully understand how the example works, because you may need to alter it to suit your actual needs.

:: Start
(set: $targets to (shuffled: ...(a: "1", "2","3","4","5")))

[[RandomizerMain]]


:: RandomizerMain
Debug: The RandomizerMain Passage.

Debug: Remaining Targets: (print: $targets)

(live: 3s)[
	(stop:)
	(if: $targets's length is 0)[
		(goto: "AllGoneThrough")
	]
	(else:)[
		(move: $targets's 1st into _target)
		(goto: _target)
	]
]


:: 1
Debug: The 1st Passage.
(live: 3s)[
	(stop:)
	(goto: "RandomizerMain")
]


:: 2
Debug: The 2nd Passage.
(live: 3s)[
	(stop:)
	(goto: "RandomizerMain")
]


:: 3
Debug: The 3rd Passage.
(live: 3s)[
	(stop:)
	(goto: "RandomizerMain")
]


:: 4
Debug: The 4th Passage.
(live: 3s)[
	(stop:)
	(goto: "RandomizerMain")
]


:: 5
Debug: The 5th Passage.
(live: 3s)[
	(stop:)
	(goto: "RandomizerMain")
]


:: AllGoneThrough
Debug: The AllGoneThrough Passage.

note: You can safely remove all of the lines that starts with Debug:, which is only there to track which Passage is currently being visited, and so you can see what is happening to the contents of the $targets Array.

1 Like

Thanks for the Help! this is exactly what i needed for my project.

And to answer this question:

I am going to show a video, and then make it go back to start after the video is done. That is all.

Again, thanks for the Help!

1 Like