Condition Groups - Floogen/FashionSense GitHub Wiki

What are Condition Groups?

Condition Groups are a collection of Conditions, which can be used with frames to determine if the animation plays or skipped.

Any number of Conditions can be bundled together to form a group, including other condition groups. The condition group is treated as a singular condition, so all sub-conditions (or any single Independent sub-condition) must result in true in order for the group to return true.

Creating Condition Groups

In order to establish conditional groups, you must first create a conditions.json at the top level of your Fashion Sense content pack (near manifest.json).

Once conditions.json has been created, you can freely create conditional groups.

Note: Each group can have any arbitrary name, so long as they are unique. Other Fashion Sense pack's conditions.json are not shared, so name uniqueness is only required within your pack.

Example conditions.json

{
  "IsDarkOutAndWalking": [
    {
      "Name": "IsDarkOut",
      "Value": true
    },
    {
      "Name": "IsWalking",
      "Value": true
    }
  ],
  "IsEatingOrDrinking": [
    {
      "Name": "IsDrinking",
      "Value": true,
      "Independent": true
    },
    {
      "Name": "IsEating",
      "Value": true,
      "Independent": true
    }
  ],
  "IsIdle": [
    {
      "Name": "CurrentFarmerFrame",
      "Value": 0,
      "Independent": true
    },
    {
      "Name": "CurrentFarmerFrame",
      "Value": 6,
      "Independent": true
    },
    {
      "Name": "CurrentFarmerFrame",
      "Value": 12,
      "Independent": true
    }
  ]
}

Example condition group usage

{
...
"IdleAnimation": [
  // Start of self-descriptive frames
  {
    "Frame": 0, // Also Dancing frame
    "Conditions": [
      {
        "GroupName": "IsIdle",
        "Value": true
      },
      {
        "Name": "IsCarrying",
        "Value": false
      },
      {
        "Name": "IsPassingOut",
        "Value": false
      }
    ]
  },
  {
    "Frame": 6,
    "Conditions": [
      {
        "Name": "IsCarrying",
        "Value": true
      },
      {
        "GroupName": "IsEatingOrDrinking",
        "Value": false
      },
      {
        "Name": "IsSick",
        "Value": false
      }
    ]
  },
  {
    "Frame": 210,
    "Conditions": [
      {
        "Name": "RidingHorse",
        "Value": true
      }
    ]
  },
  {
    "Frame": 216,
    "Conditions": [
      {
        "Name": "IsSitting",
        "Value": true
      }
    ]
  }
]
}