# Hide reuse

***hide\_reuse** is one of four specifically* [*\*choice*](https://choicescriptdev.fandom.com/wiki/Choice)*-related, conditional command, affecting the display of one or more options (the others being* [*\*allow\_reuse*](https://choicescriptdev.fandom.com/wiki/Allow_reuse)*,* [*\*disable\_reuse*](https://choicescriptdev.fandom.com/wiki/Disable_reuse) *and* [*\*selectable\_if*](https://choicescriptdev.fandom.com/wiki/Selectable_if)*).*\
\&#xNAN;*hide\_reuse是四个专门与choice相关的条件命令之一，它影响一个或多个选项的显示（其他三个分别是*allow\_reuse、*disable\_reuse和*selectable\_if）。

It is only useful when the same ***choice** is repeated several times, like in a menu or a conversation with a character, where most of the **#options** end up looping back to the main **choice**.*\
\&#xNAN;*仅当同一个选项被重复多次时，它才有用，比如在菜单中或与角色的对话中，大多数#选项最终都会循环回到主*选项。

## Usage 用法

\***hide\_reuse** can be used in two completely different, separate ways:\
\*hide\_reuse 可以以两种完全不同的、独立的方式使用：

* it can hide a single option after the player uses that option,\
  它可以隐藏玩家使用过的单个选项，
* it can hide *all* the used options in the entire scene except for any given a separate condition.\
  它可以隐藏整个场景中所有已使用的选项，除非为某个选项单独设置了条件。

However, it should be noted that either purpose of this command is only of use in those cases where you specifically intend to allow the *re-use* of some or all parts of a particular \***choice** statement. In most cases a \***choice** statement is used only once within a particular [scene](https://choicescriptdev.fandom.com/wiki/Scenes), so a *hide\_reuse condition will not be needed.*\
\&#xNAN;*然而，需要注意的是，此命令的任一用途仅适用于您特意允许重复使用特定*choice语句中部分或全部内容的情况。在大多数场景中，*choice语句仅使用一次，因此通常不需要*hide\_reuse条件。

### **Hiding a single option after using it once 单次使用后隐藏单个选项**

The following code uses [\*goto](https://choicescriptdev.fandom.com/wiki/Goto) and [\*label](https://choicescriptdev.fandom.com/wiki/Label) to *re-use* the same ***choice** statement when the player chooses either of the first two options. In essence, it allows the player to eat and sleep as many times as they wish -- until they become bored of doing so and opt instead to Go outside.*\
\&#xNAN;*以下代码利用*goto和*label指令，在玩家选择前两个选项中的任意一个时，重复使用同一个*choice语句。本质上，它允许玩家随心所欲地进食和睡觉——直到他们对此感到厌倦，转而选择外出。

```choicescript
*label Home

What do you want to do?

*choice

    #Eat.

        You eat and are not hungry anymore.

        *goto Home

    #Sleep.

        You sleep for 10 hours.

        *goto Home

    #Go outside.

        You go outside.

        *finish
```

With the addition of a ***hide\_reuse** condition on the Eat and Sleep options, we can still allow this **choice** to be re-used, but hide (i.e. not display) any option previously chosen, so the player can Eat or Sleep only once before that option disappears, so finally leaving only the Go outside option available. As follows:*\
\&#xNAN;*通过在"进食"和"睡觉"选项上添加hide\_reuse条件，我们仍可允许此*choice被重复使用，但会隐藏（即不再显示）先前选择过的任何选项。这样玩家在进食或睡觉仅一次后，该选项便会消失，最终仅保留"外出"选项可用。具体如下：

```choicescript
*label Home

What do you want to do?

*choice

    *hide_reuse #Eat.

        You eat and are not hungry anymore.

        *goto Home

    *hide_reuse #Sleep.

        You sleep for 10 hours.

        *goto Home

    #Go outside.

        You go outside.

        *finish
```

**Note:** Remember to always have an exit ***choice #option** to let the player escape the loop (i.e. the "#Go outside" option above)! You will get a "No selectable options"* [*error*](https://choicescriptdev.fandom.com/wiki/Error_messages) *if all the options have been exhausted and there is no escape option.*\
\&#xNAN;*注意：请务必始终设置一个退出*choice #选项，让玩家能够跳出循环（例如上面的“#出门”选项）！如果所有选项都已用尽且没有退出选项，将会出现“无可选选项”错误。

### **Hiding all the options in the entire scene when used once 一次性隐藏整个场景中的所有选项**

Alternatively, we can make all ***choice** options act as if they have the **hide\_reuse** condition, by simply placing the **hide\_reuse** command on a line of its own near the very top of each scene file, before any actual **choice**.*\
\&#xNAN;*或者，我们可以让所有choice选项表现得如同带有hide\_reuse条件，只需在每个场景文件的最顶部、任何实际choice之前，将*hide\_reuse命令单独放置在一行即可。

```choicescript
*hide_reuse

*label Home

What do you want to do?

*choice

    #Eat.

        You eat and are not hungry anymore.

        *goto Home

    #Sleep.

        You sleep for 10 hours.

        *goto Home

    #Go outside.

        You go outside.

        *finish
```

In the above example, each option will be displayed only until it has been selected by the player, and thereafter it will be hidden, due to that prevalent ***hide\_reuse** command at the top of the **scene**. However, it's also possible to override a prevalent **hide\_reuse** command with its opposite,* [*\*allow\_reuse*](https://choicescriptdev.fandom.com/wiki/Allow_reuse)*:*\
\&#xNAN;*在上面的示例中，每个选项只会显示到玩家选择过为止，之后由于场景顶部存在该hide\_reuse命令，它将被隐藏。不过，也可以使用其相反命令*[*\*allow\_reuse*](https://choicescriptdev.fandom.com/wiki/Allow_reuse)*来覆盖普遍存在的*hide\_reuse命令：

```choicescript
*hide_reuse

*label Home

What do you want to do?

*choice

    #Eat.

        You eat and are not hungry anymore.

        *goto Home

    *allow_reuse #Sleep.

        You sleep for 10 hours.

        *goto Home

    #Go outside.

        You go outside.

        *finish
```

In the above example, *Eat* will be selectable only once (due to the prevalent \***hide\_reuse**) but the player will be allowed to *Sleep* as many times as they like.

We can also use a \*temp command and additional conditional code to limit the number of times a particular option may be chosen. The following example will now allow the player to choose "Sleep" only three times before that option is hidden:\
我们还可以使用 \*temp 命令和额外的条件代码来限制特定选项可被选择的次数。以下示例将只允许玩家选择"睡觉"选项三次，之后该选项将被隐藏：

```choicescript
*hide_reuse

*temp count 1

*label Home

What do you want to do?

*choice

    #Eat.

        You eat and are not hungry anymore.

        *goto Home

    *if count < 4

        *allow_reuse #Sleep.

            *set count + 1

            You sleep for 10 hours.

            *goto Home

    #Go outside.

        You go outside.

        *finish
```


---

# 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/hide-reuse.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.
