---
title: Anatomy of a Rule
product: SpeedTree Modeler
version: '10'
latest_version: '10'
status: This page documents version 10. The latest version is 10.
canonical: https://docs.unity.com/en-us/speedtree-modeler/10/rules-anatomy
latest_url: https://docs.unity.com/en-us/speedtree-modeler/10/rules-anatomy.md
last_updated: 2026-11-19
generated_at: 2026-11-19T15:06:00.413Z
locale: en-us
---

# Anatomy of a Rule

> Learn about the base requirements to structure a Rule script.

A Rule script needs two complementary statements at minimum. One defines a user control, and another applies its value to a property.

> **Note:**
>
> To compose a Rule script, you must use the [Lua scripting language](https://www.lua.org/).

## Minimum functional Rule structure

To compose a basic functional Rule, you minimally have to specify two complementary statements, each represented by a code line:

1. A statement that [defines the Rule](#rule-definition), which includes the definition of a user control.
2. A statement that [sets the model property value](#property-value-setup) you want to manipulate with the user control.

The first statement outputs a variable value that the second one uses as an input. You can additionally process the variable value in between, if needed.

### Rule definition

Here's the generic syntax of a statement that defines a Rule and its user control.

```text
<variable_name> = <rule_definition_function>(<rule_name>, <reference_values>)
```

| Key element                  | Description                                                                                                                                                                                         |
| :--------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<variable_name>`            | The name of the variable that holds the value controlled by the Rule.                                                                                                                               |
| `<rule_definition_function>` | The function that defines which type of control to use in the UI (slider, checkbox...) Several [rule definition functions](./rules-speedtree-functions.md#rule-definition-functions) are available. |
| `<rule_name>`                | The name of the Rule, and optionally the name of its grouping category, in the UI.                                                                                                                  |
| `<reference_values>`         | Static values that frame the Rule according to its type, including default values.                                                                                                                  |

### Property value setup

Here's the generic syntax of a statement that sets a model property value to manipulate.

```text
<property_value_setup_function>(<target_property_identifiers>, <input_parameters>)
```

| Key element                       | Description                                                                                                                                                                         |
| :-------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<property_value_setup_function>` | Function to specify which type of property setup to perform. Several [property value setup functions](./rules-speedtree-functions.md#property-value-setup-functions) are available. |
| `<target_property_identifiers>`   | Parameters to specify which property of which object to control with the Rule.                                                                                                      |
| `<input_parameters>`              | Parameters to set the property value according to the variable `<variable_name>` controlled by the Rule.                                                                            |

{/*
  ## Best practices to structure more complex Rule scripts
  (To be done in a subsequent iteration)
  */}

## Additional resources

* [Introduction to Rules](./rules-introduction.md)
* [Create a slider Rule](./rules-create-slider.md)
* [Rule script helpers in the Property bar](./property-bar.md#rule-script-helpers)
* [Rules window reference](./rules-window.md)
* [SpeedTree functions usable in Rules](./rules-speedtree-functions.md)
* [Lua scripting reference documentation](https://www.lua.org/manual/)
