SpeedTree functions usable in Rules
Learn about the main SpeedTree functions you can call from a Rules script.
Rule definition functions
Use these functions to specify the Rule type. The Rule type defines the type of UI control to display and the Rule parameters. Use the returned values to control your model and scene properties through the property value setup functions.
<number> rule(name<string>[, default<number>][, min<number>][, max<number>])
- Makes a rule named "name" with an optional default value and range.
- The rule variable is a floating point number (1.0, 2.4, 1.985, etc.)..
<integer> rule_int(name<string>[, default<number>][, min<number>][, max<number>])
- Makes a rule named "name" with an optional default value and range.
- The rule variable is an integer (0, -5, 22, etc.).
<integer> rule_check(name<string>[, default<bool>])
- Makes a rule named "name" with an optional default value.
- The rule variable is a boolean checkbox (1 or 0).
<integer> rule_combo(name<string>, items<table of strings>)
- Makes a rule named "name" that is a combo box with each of the strings in the "items" table as the elements.
- Returns the current index.
<integer> rule_seed(name<string>[, default<int>])
- Makes a rule named "name" that is an integer with the dice icon button to randomize it.
- Returns the current seed value as an integer.
Property value setup functions
Use these functions to set properties of the model and the scene using values controlled by the Rule definition functions.
set_season(value<number>)
- Sets the value of the season slider in the range [0.0, 1.0].
set_visible(name<string>, visible<bool>, descendants<bool>)
- Sets the visibility state of the objects named "name" (and, optionally, its descendants if it's a generator).
set_property_value(object<string>, property<string>, value<any>)
- Sets the property named "property" for all objects named "object" to the specified value.
set_property_variance(object<string>, property<string>, value<number>)
- Sets the variance on the property named "property" for all objects named "object" to the specified value.
set_property_profile(object<string>, property<string>, curve<table of points { x, y[, tangent x][, tangent y] }>)
set_property_profile(object<string>, property<string>, preset<string>)
- Sets the profile curve for the property named "property" for all objects named "object" to the curve table.
- The table represents a list of x, y, tangent x and tangent y values.
- The preset is a string that matches the preset name in the curve editor dialog.
set_property_profile("Trunk", "Spine:Length:Absolute", { {x=0,y=0}, {x=1,y=1} })
set_property_profile("Trunk", "Spine:Length:Absolute", "linear growth")
set_property_parent(object<string>, property<string>, level<integer>, curve<table of points { x, y[, tangent x][, tangent y] }>)
set_property_parent(object<string>, property<string>, level<integer>, preset<string>)
- Sets the parent curve at the level specified by "level" for the property named "property" for all objects named "object" to the curve table (the table represents a list of x, y, tangent x and tangent y values).
- The preset is a string that matches the preset name in the curve editor dialog.
set_property_parent("Trunk", "Spine:Length:Absolute", 1, { {x=0,y=0}, {x=1,y=1} })
set_property_parent("Trunk", "Spine:Length:Absolute", 1, "linear growth")
randomize(generator_name<string>, seed<int>, descendants<bool>)
- Randomizes all generators named "generator_name" (and, optionally, their descendants) using the seed specified by "seed".
Property value query functions
Use these functions to query the current values of some properties in your scene.
<number> season( )
- Returns the current value of the season slider in the range [0.0, 1.0].
<number> timeline( )
- Returns the current value of the timeline slider in the range [0.0, 1.0].
timeline_frame( )
- Returns the current frame of the timeline slider as an integer.
Utility function
Use this function for troubleshooting when you design and test your Rules.
print(value)
- Prints a line in the output window every time the script runs.
- You can print any string, float, or integer value.
- You can concatenate multiple strings/values using ".."
print("hi")
print(age)
print("The age is:" .. age)