Anatomy of a Rule
Learn about the base requirements to structure a Rule script.
Note
To compose a Rule script, you must use the Lua scripting language.
Minimum functional Rule structure
To compose a basic functional Rule, you minimally have to specify two complementary statements, each represented by a code line:
- A statement that defines the Rule, which includes the definition of a user control.
- A statement that sets the model property value 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.
<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 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.
<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 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. |