How do I create links to random pages?

Is it possible to create links that go to a random page in your Quest game? And is it possible to select the list of pages that this link can go to (I don't want every page in my game to be accessible from the random link, only certain ones).


Io

YES!

What you are looking for is the command text option. When creating your text, it looks like this:

{command:NameOfTheCommand:WordsPlayerSees}

It creates a hyperlink of WordsPlayerSees that, when clicked, executes command NameOfTheCommand.

So you want a command called, I don't know, 'GoToRandomRoom', with word-input '12345'. Then you structure it like:

{command:12345:Click Me!}

Under that commands, you basically use a Switch block, switching based on a GetRandomInt. It'd look something like this (Pardon my psuedocode):

Switch Case (GetRandomInt(1,5)){:
case 1{
Move Player to room1
}
case2{
Move Player to ToothbrushRoom
}
case3{
Move Player to room3
}
etc.

To instead make a list of possible ones, you instead want to use menu:
First create a blink Stringlist
Add the possible options to it
Show the menu, with a Switch-case inside.

Like so:

WhateverYouWantToCallTheNewStringList = newStringList()

Add to WhateverYouWantToCallTheNewStringList "Option 1"
Add to WhateverYouWantToCallTheNewStringList "Option 2"

Show Menu based on WhateverYouWantToCallTheNewStringList{
after input:
Switch Case based on result{
case "Option 1"{
Move player to room99
}
case "Option 2"{
Move player to GameOverRoom
}

Hope this helps!


If you're doing a text adventure, the advice above is probably close enough that you can probably figure it out.

If you're making a gamebook, I'd suggest making a page which, when visited, immediately sends the player to a random page.

The random page would be "script" type, and would look something like this:

switch (GetRandomInt (1,4)) {
  case (1) {
    MovePlayer (page12)
  }
  case (2) {
    MovePlayer (page17)
  }
  case (3) {
    MovePlayer (page29)
  }
  case (4) {
    MovePlayer (page44)
  }
}

Which chooses a random number from 1 to 4, and then moves the player to a different room (one of 4 options) based on that number.


Thanks for the helpful responses. Is there a way to do this on Squiffy too?


Alright, both the methods Io and mrangel do indeed work, but there is also a much simpler variant when you don't need intricate redirects: {random:} will display any of the specified lines, which can also be formated or include commands/page links.

An example would look like this:

As the door slams shut behind you, you have no other choice to proceed through the dark building. There are two hallways branching of the entry, one left and on right.

{page:CorridorL:Go left}
{page:CorridorR:Go right}
{random:{page:CorridorL:Pick one at random}:{page:CorridorR:Pick one at random}}

This can get tedious fast when you need to cover many different options, but has the added bonus that you can vary the displayed text based on the command/link.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums