> ## 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 Properties

> How to attach Lua scripts to elements in the RollingQuest editor: script references, tags, and local variables.

Script Properties allow you to attach Lua scripts to any element in the level. Each element (level, block, side, item, enemy, ball, decoration) can have its own script with custom tags and variables.

## Opening Script Properties

From the Element Properties panel (**V**), click **Script** (or **Block Script** / **Side Script** for blocks).

## Configuration

### Script Reference

The name of the script in the level's script collection. You can:

* Type the script name directly in the input field
* Click **More Scripts** to open the Script Editor in select mode

### Script Tag

A string identifier for this specific element instance. Tags are used in Lua scripts to identify which entity triggered a hook or signal.

Example: If you tag an enemy as `"boss_01"`, your script can check `self.tag == "boss_01"` to apply boss-specific behavior.

### Local Variables

Key-value pairs accessible from the script. These are stored as `LuaLocalVariablesDefinitions` on the element.

* Click **New Variable** to add a variable
* Enter a variable name and value
* Variables are accessible in Lua as `self.vars["variableName"]`

## Supported Element Types

| Element    | ScriptElementType | Access                            |
| ---------- | ----------------- | --------------------------------- |
| Level      | `Level`           | Level Properties → Script         |
| Block      | `Block`           | Element Properties → Block Script |
| Side       | `Side`            | Element Properties → Side Script  |
| Item       | `Item`            | Element Properties → Script       |
| Ball       | `Ball`            | Element Properties → Script       |
| Enemy      | `Enemy`           | Element Properties → Script       |
| Decoration | `Decoration`      | Element Properties → Script       |

## Variable Management

### Creating Variables

1. Click **New Variable** in the Script Properties panel
2. Enter a variable name (must be unique)
3. Select the variable type (String, Integer, Float, Boolean)
4. Set the initial value
5. Click **Accept**

### Editing Variables

* Click on a variable's value to edit it
* Changes are applied immediately

### Deleting Variables

1. Click the remove button on a variable
2. Confirm in the popup
3. The variable is removed from the element

## How Scripts Use Properties

In Lua scripts, element properties are accessed through the `self` object:

```lua theme={null}
function OnStart(self)
    -- Access the script tag
    local tag = self.tag

    -- Access local variables
    local speed = self.vars["speed"]
    local name = self.vars["name"]
end
```

<Note>
  Script variables are per-element instance. Two enemies of the same template can have different variable values, allowing unique behavior for each instance.
</Note>
