> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/scripting/script-modifiers.md).

# Script Modifiers

### Creating a Script Modifier

To create a Script Modifier, secondary-click inside a **Modifier Node Editor** and navigate to:

**Utility → Script**

<div align="left"><figure><img src="/files/0vxtNOVH2fxctMEMXbGv" alt="" width="563"><figcaption></figcaption></figure></div>

Alternatively, search for **Script** directly in the node menu and select the Script node from the results.

<div align="left"><figure><img src="/files/uCRn6K0KIIDtWtVAQrJj" alt="" width="310"><figcaption></figcaption></figure></div>

A newly created Script node starts without any input or output pins.

<div align="left"><figure><img src="/files/5MUPqOcBxoLmvX6bxGZ2" alt="" width="264"><figcaption></figcaption></figure></div>

### Adding Inputs and Outputs

Select the Script node and open the **Parameter** tab in the Inspector.

Click the **+** button to add a new Parameter and choose whether it should be an **Input** or **Output**.

<div align="left"><figure><img src="/files/vgCruS8MrPFUKNEHhgJ0" alt="" width="458"><figcaption></figcaption></figure></div>

After adding the pin, configure its data type and double-click its name to rename it.

For example, a Script Modifier could contain:

```
Inputs
- MyInput
- MyInput2

Outputs
- MyOutput
```

<div align="left"><figure><img src="/files/SmigynLUaaT7KDENPTxW" alt="" width="167"><figcaption></figcaption></figure></div>

The names assigned to the pins are also the names used to access them inside the script.

For example:

```python
MyOutput = MyInput * 2
```

{% hint style="info" %}
Pin names are used directly as variable names inside the Script Modifier. Use clear names that are also valid for use in the script.
{% endhint %}

Additional input and output pins can be added in the same way whenever the Modifier requires more values.

### Editing the Script

Select the Script node and open the **Script** tab in the Inspector.

<div align="left"><figure><img src="/files/tmllyYh9abV9e1oSaM6S" alt="" width="445"><figcaption></figcaption></figure></div>

The Script Editor is embedded directly in the Inspector and can be edited without opening a separate window.

The configured input and output pin names are available directly as variables inside the script.

For example:

```python
MyOutput = MyInput + MyInput2
```

In this example, the values of `MyInput` and `MyInput2` are combined and the result is assigned to `MyOutput`.

{% hint style="info" %}
Unlike Project Scripts and Workflow Script Actions, the Script Modifier editor is embedded directly in the Inspector and does not open as a separate floating Script Editor.
{% endhint %}

### Processing Values

Once the inputs and outputs have been configured, they can be used directly inside the Script Modifier.

For example:

```python
MyOutput = MyInput * 2
```

The script reads the current value from `MyInput` and assigns the processed result to `MyOutput`.

Multiple inputs can also be used as part of the same processing logic:

```python
MyOutput = MyInput + MyInput2
```

The resulting output values are then available from the corresponding output pins of the Script node.

### Multiple Outputs

Multiple output Parameters can be defined when a Modifier needs to produce more than one result.

Each output is accessed using the name assigned to it in the Inspector.

This allows one Script Modifier to process incoming data and provide several results through its output pins.

### Run Modes

The Script Modifier can be configured to run in different ways using **Run Mode** in the Inspector.

#### On Input Change

With **On Input Change**, the script is evaluated whenever one of its input values changes.

This is useful for reactive processing where the output should automatically update when new input data is received.

#### On Trigger

With **On Trigger**, the Script node receives an additional **Run** input pin.

The script is only evaluated when a Trigger is received through this pin.

This mode is useful when the calculation should be controlled explicitly rather than running whenever an input value changes.

### When to Use Script Modifiers

Script Modifiers are useful when custom processing should behave like a normal Modifier node with clearly defined inputs and outputs.

Typical use cases include:

* Mathematical calculations
* Value conversion
* Custom data processing
* Creating reusable processing logic
* Producing one or more values from incoming data

For logic that needs access to dynamic Workflow data and control over Workflow branches, use a **Workflow Script Action** instead.
