0 votes
by (120 points)
I am just beginning a new project and want to link to a random URL. For example, If passage 1 said: I love [[cats]], then I would want the user to be able to click on cats and have it bring them (outside of the project) to one of the top 10 hits on google news for "cats." Again, I haven't started yet so I haven't picked a story format -- I will use whatever I can to make this work. I am partial to sugarcube, however. Any and all help would be greatly appreciated!!

2 Answers

0 votes
by (420 points)
edited by

The way I would do it in Sugarcube is set each url as a variable.
so ex

<<set $firstURL to 1>>

then use random to make the variable be randomly chosen between 1-10


then make another variable to be set as the one that grabs the URL chosen, and place that inside your passage link

EDIT: Ahh nevermind: I read that wrong, I thought the URLs were predetermined.   I guess you would need to be pulling APIs like Chapel mentioned...

0 votes
by (63.1k points)

If you want this to actually be automated in some way, meaning you want a dynamic set of links straight from Google to use in your story, you'll need to use their API, which is only sort of free. Then you'd grab the urls from the data and create some links. 

How easy this is for you to implement will depend on your programming knowledge. My knowledge of how to do something like this basically begins and ends with knowing that it can be done, so I can't offer you much more help than that, unfortunately.