Lookup Anything

Lookup Anything

391k Downloads

[Content Patcher] EditData - Entries with tokenised keys cannot have tokenised values

b-b-blueberry opened this issue · 2 comments

commented

Issue
When editing a data model, any entries with "{{Tokens}}" in the key will have their tokenised values left unresolved. If the value is a data model, none of its entries will be tokenised either.

Example:

"DynamicTokens": [
    {
        "Name": "PATH",
        "Value": "Mods/CPNestedModelTokenTest"
    },
    {
        "Name": "KEY",
        "Value": "TokenisedKey"
    }
]
// Entries:
"SimpleDictionary": {
    "UntokenisedKey_SimpleDictionary": "{{PATH}}/String",
    "{{KEY}}_SimpleDictionary": "{{PATH}}/String"
}
// Exported:
"SimpleDictionary": {
  "UntokenisedKey_SimpleDictionary": "Mods/CPNestedModelTokenTest/String",
  "TokenisedKey_SimpleDictionary": "{{PATH}}/String"
}

Attachments
Log: log.smapi.io
Patch export: json.smapi.io
Repro solution and content pack: CPNestedModelTokenTest.zip

commented

This appears to be due to how when the 'Name' / 'Key' of the Property contains tokens, when the token changes it will replace the property with a new one with the existing value.

if (!this.TryInjectJsonProxyField(property.Name, assumeModIds, val => property = this.ReplaceJsonProperty(property, new JProperty(val, property.Value)), localPath.With("key"), out error, out TokenizableProxy? proxyName))

However, this would result in the property reference to change, causing the token change for the 'value' to point at the old property.

commented

Fixed in the upcoming Content Patcher 1.27.0 via #1108. Thanks for reporting it!