StardewMods icon indicating copy to clipboard operation
StardewMods copied to clipboard

[Content Patcher] Add content-pack-provided tokens

Open Pathoschild opened this issue 5 years ago • 1 comments

SMAPI mods can define mod-provided tokens for content packs to use, but there's currently no way to expose tokens between two content packs. Add some way for content packs to define their own mod-provided tokens.

Pathoschild avatar Oct 17 '20 00:10 Pathoschild

One possible approach would be a ModProvidedTokens field that lets you list any config or dynamic tokens:

{
   "Format": "1.18.0",
   "DynamicTokens": [
      {
         "Name": "IsTownPatched",
         "Value": "{{EnableMapChanges}}" // config token
      }
   ],
   "ModProvidedTokens": [ "IsTownPatched" ]
}

Then another content pack can access those tokens, if it has a dependency or HasMod check (just like regular mod-provided tokens). For example, if the above mod has ID Pathoschild.SampleMod:

{
    "Format": "1.18",
    "Changes": [
      {
         "Action": "EditMap",
         "Target": "Maps/Town",
         "FromFile": "assets/town.tbin",
         "When": {
            "Pathoschild.SampleMod/IsTownPatched": true
         }
      }
   ]
}

Pathoschild avatar Oct 17 '20 01:10 Pathoschild