# Goto\_scene

The \*goto\_scene command is used in the same general manner as an ordinary \*goto, but instead of a label name reference within the same scene file, it requires a specific scene name to load; this being a particular .txt file in your "scenes" (..\mygame\scenes) folder. \*goto\_scene can load any scene file, whether or not that file is included in the \*scene\_list section of startup.txt.\
\*goto\_scene 命令的使用方式与普通的 \*goto 大致相同，但区别在于：它需要的不是同一场景文件内的标签名引用，而是一个要加载的特定场景名称；这指的是你 "scenes" 文件夹（路径为 ..\mygame\scenes）中一个具体的 .txt 文件。\*goto\_scene 可以加载任何场景文件，无论该文件是否包含在 startup.txt 的 \*scene\_list 部分中。

## Usage 用法

\*goto\_scene is one of two very different commands enabling the proper use of multiple different scene .txt files in your game (thereby essentially making it unlimited in scope and size); the other being the \*finish command.\
\*goto\_scene 是两个截然不同的命令之一，它们使得在你的游戏中正确使用多个不同的场景 .txt 文件成为可能（从而在范围和规模上基本实现了无限可能）；另一个命令是 \*finish。

There are some key differences between \*goto\_scene and \*finish:\
\*goto\_scene 和 \*finish 之间存在一些关键区别：

* \*goto\_scene allows you to jump to any scene in the scenes folder, whereas \*finish only loads the next sequential scene in the startup.txt \*scene\_list.
  * \*goto\_scene 允许你跳转到 scenes 文件夹中的任何场景，而 \*finish 仅加载 startup.txt 的 \*scene\_list 中下一个顺序的场景。
* using \*goto\_scene, you can specify where in the called scene you wish to go by adding the name of a label in that scene. 使用 \*goto\_scene 时，你可以通过添加目标场景中某个标签的名称来指定希望跳转到该场景的哪个位置。 \*goto\_scene is typically used as follows:\
  \*goto\_scene 的典型用法如下：

```
Where do you want to go?

*choice

  #To the park.

    You decide to go to the park.

    *page_break End of Scene

    *goto_scene park

  #Home.

    You decide to go home.

    *page_break End of Scene

    *goto_scene home

  #To the City Hall.

    You decide to go to City Hall.

    *page_break End of Scene

    *goto_scene cityhall
```

The scene referenced with a \*goto\_scene command must exist in the scenes folder. For example, for the above code to work properly, in the scenes folder for this game the following files must be present:\
使用 \*goto\_scene 命令引用的场景必须存在于 scenes 文件夹中。例如，为了使上述代码正常工作，该游戏的 scenes 文件夹中必须包含以下文件：

* `cityhall.txt`
* `home.txt`
* `park.txt`

要跳转到被调用场景中的特定 `*label`，你可以这样写：

```
*goto_scene [scene file] [label]
```

例如，如果"home.txt"文件包含多个 `*label`，其中一个名为 "Fire"，你可以通过输入以下内容跳转到该场景的那个部分：

```
*goto_scene home fire
```

这将跳过home.txt场景中"fire"标签之前的任何内容。

## Important note 重要提示

{% hint style="warning" %}
It is worth bearing in mind that any *temp variables (and their current values) created in the current scene file will be lost from memory the instant that a new scene file is loaded using the goto\_scene command. Where this may cause continuity problems in your story / scripting, you should instead define those variables using the create command in startup.txt.*\
\&#xNAN;*需要记住的是，当前场景文件中创建的任何temp变量（及其当前值）会在使用goto\_scene命令加载新场景文件的瞬间从内存中丢失。若这种情况可能导致故事/脚本的连续性出现问题，则应在startup.txt中使用*create命令定义这些变量。
{% endhint %}

## Advanced Scene Scripting Notes 场景与startup.txt \[高级场景脚本说明]

Scenes intended to be loaded sequentially, using the *finish command, must be included in the scene\_list section of the startup.txt file located in the "scenes" (..\web\mygame\scenes) folder. However, if you only ever direct the scene file loading using the specific goto\_scene \[scene name] command, only your very first, opening scene file need be listed in the scene\_list, as its only purpose is to direct a finish command.*\
\&#xNAN;*计划通过finish命令顺序加载的场景，必须包含在位于"scenes"文件夹（..\web\mygame\scenes）内startup.txt文件的scene\_list部分中。然而，如果仅通过特定的goto\_scene \[场景名称]命令来引导场景文件加载，则只需在scene\_list中列出最初的开场场景文件，因为其唯一用途是引导*finish命令的执行。

Note also that you should never use *goto\_scene to return to startup.txt from another scene file without also referencing a specific label to jump to. Doing so will cause ChoiceScript to reset all permanent variables back to their original default values (i.e. on loading it effectively reruns the entire list of create commands present in that file). Referencing a specific label in startup.txt, somewhere below all the create commands, will however avoid this problem.*\
\&#xNAN;*还需注意，切勿在未指定具体label跳转目标的情况下，使用goto\_scene从其他场景文件返回至startup.txt。否则将导致ChoiceScript将所有永久变量重置回初始默认值（即加载时实际上会重新执行该文件中所有create命令）。然而，若在startup.txt中所有create命令之后的位置指定具体*label进行跳转，则可避免此问题。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://raster.gitbook.io/zh-hans_choicescript-guide/goto_scene.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
