(Harlowe) How to set random passages to one link?

0 votes
asked Dec 6 by LizzieFlynn200 (160 points)
I'm using Harlowe 2.0.1 to make a simple game about Malala for a Social Studies project, and I want to make a link that shuffles through six variables to send the player to one of six different passages. Is this possible, or do I need to simplify/change my idea?

Thank-you in advance.

1 Answer

+1 vote
answered Dec 6 by greyelf (43,790 points)

You could use the (array:) macro to create a collection of Passage names, then use the (shuffled:) macro to randomly sort those names, and finally a (link-goto:) macro to create the link using the 1st element in the shuffled array as the name of the Target Passage.

(set: _list to (array: "Passage 1", "Passage 2", "Passage 3", "Passage 4", "Passage 5", "Passage 6"))

(link-goto: "Next", (shuffled: ..._list)'s 1st)

... obviously your Passage names would be more meaningful than the ones in the above example.

note: You don't state what type of value is stored within your "six variables" but if you really need to use there value as the determining factor and if those six variables contain the Passage names then you could build the Array of Names using them like so.

(set: $passageA to "Passage 1")
(set: $passageB to "Passage 2")
(set: $passageC to "Passage 3")
(set: $passageD to "Passage 4")
(set: $passageE to "Passage 5")
(set: $passageF to "Passage 6")

(set: _list to (array: $passageA, $passageB, $passageC, $passageD, $passageE, $passageF))

... and then use the same (link-goto:) macro as the first example.

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...