Linking to a random passage within a set

I’m intending to start on a project which is a collection of poems, wherein clicking on a particular phrase will take you to a random other poem which uses a similar phrase, with several such links per poem. I know I could use link-goto with either, but that’d mean manually putting every passage into every other passage that has to link to it. So I’m wondering whether there’s a more efficient way of doing it - if for example there’s a way of adding “tags” to passages, then writing links which lead to a random passage with a particular tag. Would be very grateful for any advice.

Yeah, you could use tags, and Story.lookup to find the passages. So either(Story.lookup('tags', 'elephant')) should get you a random one.

2 Likes

Thanks - this is a basic question but how do I put that into the link format?

<<link 'Link text' `either(Story.lookup('tags', 'elephant')).title`>><</link>>

Note that this code is for Sugarcube, so if you’re using another format it won’t work. You should always specify which format you’re using when asking for help.

3 Likes

I’m guessing Harlowe by the OP’s mention of “link-goto”. Still, sage advice about mentioning the story format.

OP, please always tag your posts with an appropriate story format tag or, mention it in the post body, or both—e.g., tag it harlowe and mention the specific version in the post.

Story formats are not simply skins or themes for some universal “Twine engine”, they are the engines and most modern formats are fairly different from each other in the details.

I hadn’t yet decided on a format - I was hoping somebody could tell me which format would work best for this sort of project. Sorry if that created confusion!