# Flags

Flags allow you to make your scripts more reusable and dynamic. A flag is a simple on/off switch that can be checked in conditions within scripts, sections, or actions.

A typical use case is enabling or disabling sounds for late-night running sessions — create a "Sound" flag and use it as a condition on all sound-related actions.

## Creating flags

Flags can be created from the [profile](/docs/manual/profile.md) screen under the automation section. Each flag has a name and an optional default state (enabled or disabled at startup). You can also configure whether the flag appears in the throttle for quick toggling.

## Scoping

For fine-grained control, flags can be active at three levels. During evaluation, if a flag is active at **any** of these levels, the condition is evaluated as true.

### Global

When you enable or disable flags in the throttle (under the automate tab), you do so at the **global** scope — these flags are active for all scripts.

### Script

With the [set flags](/docs/manual/automation/scripts/action/structure.md#set-flags) action, you can activate specific flags within your script. These flags are only active for that specific script run. Setting script-level flags replaces any previously set flags at this level.

### Vehicle

You can enable flags on a specific [vehicle](/docs/manual/vehicles.md). These flags become active when that vehicle is selected in a script — via the [select vehicle](/docs/manual/automation/scripts/action/vehicle-control.md#select) action, the "select active vehicle" option of an execution event, or the [select from feedback](/docs/manual/automation/scripts/action/vehicle-control.md#select-feedback) action. As soon as another vehicle is selected, the previous vehicle's flags are no longer active.

{% hint style="info" %}
Once a flag is active at any level, it cannot be disabled from another level. For example, if a flag is enabled globally, a script cannot disable it by omitting it from the script-level flags.
{% endhint %}

## Using flags

Flags can be used in three places:

* **Conditions** — On actions, sections, or scripts. Check whether a flag is enabled or disabled.
* **Execution events** — Not directly, but conditions on event-triggered scripts can check flag state.
* **Vehicle profiles** — Combine flags with vehicle-specific behaviour to create context-dependent automation.


---

# 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://modeltrainscript.gitbook.io/docs/manual/automation/flags.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.
