Selection Actions
What can be done inside selection blocks? Well selection actions of course, of which there are multiple types of, described here, from least to most advanced.
Nested Selection Blocks
The simplest thing you can do inside a selection block, is nest more selection blocks, This is basically treated as adding an intersection selector between the outer selection blocks selector and the inner selection blocks selector.
Here the outer selector block matches every single part, while the inner one only matches those matching the #wheel_0v_rover
name selector as well.
Deleting the objects
You can very easily delete objects inside of selector blocks using the @delete
statement followed by a semicolon.
This selection action will delete any parts that match the #wheel_0v_rover
name selector.
Setting an objects value
You can also set an objects value directly using a selection block using the @set
statement followed by the value and a semicolon.
This will set the value of the wheel_0v_rover
definition to
(which will actually crash the game, so don't test this one like this)
Merging an objects value with a dictionary
You can merge an objects value with another dictionary/object using the @merge
statement followed by the value to merge with and a semicolon.
This will merge the wheel_0v_rover
with the object after it, either adding a mass field or setting it to 5.
Setting a field in an object
You can set fields in an object using a few ways, the simplest way is to just set a field directly like follows
Field Indexers
But sometimes the field is an array or dictionary, and you want to set a specific index of it, this is where you can do the following,
Define a Variable
Sometimes you want a value that you can reference in this block, and blocks below it, this is what a variable is for, they are defined as follows $variable-name: ...;
where ...
is the expression/value you wish to assign to the variable
Conditionally run selection actions
These next 2 selection actions are going to be a bit more advanced than the rest, but sometimes you may want to run some actions conditionally, and the selectors/filters aren't enough to narrow down this condition, this is where @if
, @else-if
, and @else
blocks come in. It's best to just show these in action.
The @else-if
and @else
blocks are completely optional, you can have an infinite amount of @else-if
blocks, and can have zero or one @else
blocks, but the @else
block must always be last, and the @else-if
blocks must always be after the @if
block. And inside these blocks you can have any selection action described on this page
Include a mixin
For more of an explanation on mixins read the Mixins Tutorial in the Advanced Section. But for showing how to include a mixin, without much other explanation:
Now that we've gone over these selection actions, you might have noticed a lot of references to stuff such as values, variables, or expressions, which will be explained in the next topic Values, Variables, and Expressions