Tractor Mod

Tractor Mod

130k Downloads

[Content Patcher] support variants

Pathoschild opened this issue ยท 4 comments

commented

It's common for XNB mods to come in multiple versions (e.g. dark wood bridge vs light wood bridge). Look into supporting this in content.json, so modders don't need to create separate downloads for each version.

commented

One option is an Enabled flag so players can toggle the one they want:

{
    "Format": "1.0",
    "Changes": [
        // Labrador Retriever
        {
            "Action": "Load",
            "Target": "Animals/dog",
            "FromFile": "assets/labrador-retriever.png",
            "Enabled": true
        },

        // Bulldog
        {
            "Action": "Load",
            "Target": "Animals/dog",
            "FromFile": "assets/bulldog.png",
            "Enabled": false
        }
    ]
}
commented

The Enabled flag was added via #192; I'll keep this open a for bit in case we think of a way to handle variants specifically.

commented

One option is to support config tokens:

{
   "Format": "1.0",
   "Config": {
      "Variant": "DarkWood",
      "EnableFloors": true
   },
   "Changes": [
      {
         "Action": "Load",
         "Target": "Flooring",
         "FromFile": "assets/{{variant}}/floors.png",
         "Enabled": "{{EnableFloors}}"
      }
   ]
}

Maybe let modders set optional restrictions on field values, so users get helpful errors (like "Skipped Content Pack Name: the 'variant' field must be one of "DarkWood", "LightWood", or "Crystal""). For example:

   "ConfigSchema": {
      "Variant": {
         "Values": ["DarkWood", "LightWood", "Crystal"]
      },
      "EnableFloors": {
         "Type": "boolean"
      }
   }

This lets modders create much more flexible content packs with less duplication, and we could extend it with dynamic tokens like {{season}} for seasonal assets.

commented

Done with patch conditions (#206), config values (#207), and tokens (#208).