[A17-3008] Overrides in mixintos

In the latest update, we get this improvement :

  • Added a way for modders to specify that a certain part of a mixinto will override an entire node. Usage example — “mixintype_given_names”: “override” . This allows us to replace arrays instead of adding to them

How to use it exactly? I tried to use “override” in some places but always get an error.

2 Likes

@yshan: could you put up an example somewhere?

2 Likes

Hi,
(hopefully the russian translation mod creator is okay with me using one of his/her files as an example)
Here’s an example of how to mixin to the ascendancy population file to replace all of the English names with Russian ones.
In the past, you had to completely override the ascendancy population file, which would result in bugs when the game updated because users would have an older version of the population file. With the new “mixintype_given_names”:“override”, you can put the attached file below as a mixin instead of an override in the mod’s manifest. This will allow the population file to pick up new changes when the game updates.

ascendancy_population.txt (7.0 KB)

Please let me know if you have any more questions or run into any issues.
Thanks!
-Yang

3 Likes

Thanks a lot :smiley: This is really useful for my mod. Will you add more “mixintype” in the future ? A “delete” function would be nice.

If we put an empty array it works? xD

So… The pattern is “mixintype_arrayname”, I see :slight_smile:

Is there something similar for the other files as well? For example if i want to change one function of a component in lua code. I now copy the complete component, change the function an added to my manifest in the override section. The same for some html en js files. Example for a mage class (job) I added twilight and mana as attributes and added a purple percentage bar of mana to the ui of the character screen. For a little change in the html I copied the complete HMTL changed one little bit and override the file with the new file form my mod.

For the moment that’s not possible, you have to stick to overrides for non JSON files.
But in the future we should have a way to mixin things to the UI and also Lua files if possible.

1 Like

Seems the " “mixintype_given_names”:“override” " command doesn’t work with A18. Any help ?

It’s now "mixintypes": { "given_names": "override" }. See this document for further information.

2 Likes

Thanks a lot :smiley:

maybe it just bothers me more since I work with designs of frameworks, system and data…

Having “meta-properties” like “mixintypes” in a regular data object is kinda awkward if it cannot be differentiated distinctly from the document itself. Currently, this is in the process that evaluates the json, which must check for the special “mixintypes” and process them separately.

What if there are more such “meta-properties” (or directives) required in the future?

May not be feasible, or practical, but the following is just a small suggestion:
prefix all meta-property with a special guard that marks them as such, so that they can never be confused with usual properties.

e.g.

// assume the following is body of some json object/node
{ 
    "mixintypes" : "this is a REGULAR property",
    "@mixintypes" : {  "mixintypes" : "override"  }, // this tells us that the child property "mixintypes" above should use override mode.

    "@mixintype" : "merge"  // alternative way to specify that THIS node should be merged, instead of being specified in the parent's "@mixintypes". 
}

For a processor that does not recognize or need to process the meta-properties or directives, the properties starting with “@” will be stripped. i.e. the above json data is really:

{ 
    "mixintypes" : "this is a REGULAR property"
}

EDIT: comments can be added into any json node as well using “@comment” property? even if it cannot be recognized by a processor, it will be recognized as that it should be excluded from the data.