Goto random scene

The *goto_random_scene command is an easy means of directing a game to a scene selected completely at random, choosing from a specified list of available scene files. The scene names listed below the command do not need to be included under the *scene_listarrow-up-right in startup.txtarrow-up-right. *goto_random_scene 命令是一种便捷的方式,可引导游戏完全随机选择场景,从指定的可用场景文件列表中挑选。该命令下方列出的场景名称无需包含在 startup.txt 文件的 *scene_listarrow-up-right 之下。

Usage 用法

In the following example, our protagonist has escaped from a dungeon via a subterranean system but has no way of knowing precisely where they will emerge. 在以下示例中,我们的主人公通过地下系统逃离了地牢,但无法确切知道他们将出现在何处。

As the player has no control over this, we are using *goto_random_scene to determine how the story will unfold from this point onwards. 由于玩家对此无法控制,我们使用 *goto_random_scene 来决定故事从此刻起将如何展开。

You stumble down the pitch-black tunnel, around many twists and turns,
feeling your way along the slimy wall. Just as you begin to despair of
ever again seeing daylight, from directly ahead a faint breeze suddenly
caresses your face with a promise of salvation...

*page_break

*goto_random_scene
    summer_meadow
    dank_woodland
    craggy_hillside

As this example demonstrates, the most useful purpose of *goto_random_scene is to add significant random variety to a game, for such as replay value. In the above example, each of the listed scene files would likely contain several different encounters, perhaps only eventually merging at some point much later in the story. 正如本例所示,*goto_random_scene 最有用的目的是为游戏增添显著的随机多样性,例如提升重玩价值。在上述示例中,每个列出的场景文件可能包含几种不同的遭遇,也许最终只在故事后期某个时刻才会汇合。

If the intention is to offer only slight variation at this stage in the story, this is perhaps best achieved within a single scene file using the *randarrow-up-right command to randomly choose between two or more *labelsarrow-up-right - essentially achieving the same effect on a smaller scale, or for a shorter period of time. *goto_random_scene is therefore primarily of use for games of a very particular nature and design, e.g. where significant and extended branching is intended to be a main feature of the story. 如果意图是在故事的这个阶段仅提供轻微的变化,这或许最好在单个场景文件中实现,使用 *randarrow-up-right 命令在两个或多个 *labelarrow-up-right 之间随机选择——本质上是在较小规模或较短时间范围内达到相同的效果。因此,*goto_random_scene 主要适用于具有非常特定性质和设计的游戏,例如,其中显著且广泛的分支旨在成为故事的主要特色。

Random Scene Limitations 随机场景的限制

It's worth noting that a particular scene file may be used as a random scene only once during any single playthrough (although you may still use *goto_scenearrow-up-right [name] to force the game to reload that scene at any later time, if so desired). This is in place to prevent the game randomly returning the player to the exact same scene a second or subsequent time, for example in the event that your code either returns to the same *goto_random_scene list, or also includes that particular scene file in another, later *goto_random_scene command. 值得注意的是,在任意单次游戏进程中,特定场景文件仅能作为随机场景被调用一次(尽管您仍可在后续任意时刻使用 *goto_scenearrow-up-right [name] 强制游戏重新加载该场景)。此机制旨在防止游戏随机将玩家再次或多次送回完全相同的场景,例如当您的代码既返回至同一 *goto_random_scene 列表,又在后续其他 *goto_random_scene 指令中包含了该特定场景文件的情况。

In essence, the above example will cause a game-stopping error in the event that all three listed scenes have already each been called once during the current playthrough. If you do intend to use such a code loop - or multiple *goto_random_scene commands in different places, all using the same list of scene names - then some extra code will be needed to prevent this error occurring in-game, along the following lines: 本质上,若当前游戏进程中已调用过示例所列全部三个场景,上述示例将导致游戏运行中断的错误。若您确实需要构建此类代码循环——或在多处使用多个 *goto_random_scene 指令且均采用相同场景列表——则需按以下方式添加额外代码以防止游戏内出现此错误:

First *createarrow-up-right a permanent variable in startup.txt, to carry a value of yet-to-be-visited random scenes, e.g. 首先,在 startup.txt 中创建一个永久变量,用于存储尚未访问的随机场景数量,例如:

This allows you to use the current value of the variable as a condition anywhere within your code, as follows: 这样,你就可以在代码中的任何地方使用该变量的当前值作为条件,如下所示:

In the above example, as soon as all of the random scenes have been visited once at some point during this playthrough, the value of scenes_remaining will be zero and the *goto_random_scene command will be bypassed, effectively avoiding the error mentioned above. 在上面的例子中,一旦在本轮游戏过程中所有随机场景都已被访问过一次,scenes_remaining 的值将变为零,*goto_random_scene 命令将被跳过,从而有效避免上述错误。