Skip to content

Allow IfSpecies to accept an array of species#1184

Open
Wexit11 wants to merge 4 commits into
DynamicTreesTeam:release/1.21.1from
Wexit11:develop/1.21.1
Open

Allow IfSpecies to accept an array of species#1184
Wexit11 wants to merge 4 commits into
DynamicTreesTeam:release/1.21.1from
Wexit11:develop/1.21.1

Conversation

@Wexit11
Copy link
Copy Markdown

@Wexit11 Wexit11 commented Jun 2, 2026

Overview
This change allows IfSpecies to accept a single string species or an array of string species. The logic has been updated to evaluate to true if any of the species match.
The existing functionality when a species is invalid/can't be found is that NULL_OPERATOR is returned, causing the IfSpecies branch always return 0. I've maintained this functionality, but only in the event that there are no valid species in the list.

Justification
This is purely a quality of life change to allow a subset of trees to be represented with less verbose json. Effectively, these two json objects accomplish the same result:

before, chained species
      "chance":  {
        "math": { "species":  ["birch_bush", 1, {"species": ["oak_undergrowth", 1, {"species": ["spruce_bush", 1, { "ifgt": ["noise", 0.8, {"mul": [ "noise", 0.5]}, 0.0] }]}]}]}
      },
after, a list of species
      "chance":  {
        "math": { "species":  [["birch_bush", "spruce_bush", "oak_undergrowth"], 1, { "ifgt": ["noise", 0.8, {"mul": [ "noise", 0.5]}, 0.0] }]}
      },

Testing

IfSpecies with array of valid species
Showing that the array of species is using a different chance value from the rest of the species
image
Bushes have 100% chance, all others use a noise function to place clusters.
image
image
Bushes shown to be using a non-noise based chance.

IfSpecies with single string species
Regression for single entry species
image
image
image

Regression for invalid species in array
Testing with only one species that is invalid - all species in array are invalid
image
image

image image Because NULL_OPERATOR is returned, the entire IfSpecies chain is rejected and does not execute; hence no trees are generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant