Content Patcher

Content Patcher

378k Downloads

[Content Patcher] Add content-pack-provided tokens

Pathoschild opened this issue ยท 1 comments

commented

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.

commented

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
         }
      }
   ]
}