> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rollingquest.kramgames.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Script Editor

> Using the built-in Script Editor in the RollingQuest level editor: creating, editing, deleting, and selecting Lua scripts.

The Script Editor is a built-in tool for managing Lua scripts directly within the level editor. Press **C** to open it.

## Opening the Script Editor

Press **C** from the editor viewport, or access it through the Level Properties menu.

## Script Management

### Creating Scripts

1. Click **Create** in the Script Editor
2. Enter a unique script name in the input field
3. Click **Create** to confirm

The script is added to the level's `LuaScriptsCollection` and appears in the script list.

### Editing Scripts

1. Select a script from the list on the left
2. The script's source code appears in the text editor on the right
3. Edit the Lua code directly
4. Changes are saved automatically when you switch scripts or close the editor

### Deleting Scripts

1. Select a script from the list
2. Click **Delete**
3. Confirm in the popup

<Warning>
  Deleting a script removes it from the level. Any elements referencing this script will lose their script attachment.
</Warning>

### Selecting Scripts (Assign Mode)

When opened from an element's script properties:

1. The editor opens in **Select Mode** — the Select button is visible
2. Select a script from the list
3. Click **Select** to assign it to the element
4. The editor closes and returns to the Element Properties panel

## Script List

The left panel shows all scripts in the level's `LuaScriptsCollection`:

* Scripts are sorted alphabetically
* The currently selected script is highlighted
* The list updates when scripts are created or deleted

## Text Editor

The right panel contains an in-game text editor with:

* Multi-line text editing
* Caret positioning
* Copy/paste support
* Automatic saving when switching scripts

## LuaDoc Manual

The Script Editor includes an integrated Lua documentation browser:

* Access Lua API documentation without leaving the editor
* Browse available hooks, signals, classes, and functions
* Reference while writing scripts

## Modes

| Mode            | Description                                |
| --------------- | ------------------------------------------ |
| **Editor**      | Normal mode — create, edit, delete scripts |
| **New Script**  | Prompt for new script name                 |
| **Want Delete** | Confirmation dialog for deletion           |
| **Select**      | Choose a script to assign to an element    |

## Script Storage

Scripts are stored in the level's `LuaScriptsCollection` and saved with the level data. Each script has:

* **Name** — Unique identifier
* **Source Code** — Lua source text
* **Is Teal** — Whether the script uses Teal (typed Lua) — currently always `false`

<Note>
  The Script Editor auto-saves changes when you switch between scripts. There is no manual save button — editing is continuous.
</Note>
