CCDirectLink / CCLoader

Modloader for crosscode
38 stars 8 forks source link

Add patchstep "MERGE_CONTENT" (...and add 'v' to mod option version display) #96

Closed elluminance closed 2 years ago

elluminance commented 2 years ago

MERGE_CONTENT would simply allow one to bulk add/modify many keys or array elements all at once.

To give an example, with an initial state of:

{
    "a": 1,
    "b": 2
}

and a patchstep of:

{
    "type": "MERGE_CONTENT",
    "content": {
        "a": 3,
        "c": 4
    }
}

It would modify the state to be:

{
    "a": 3,
    "b": 2,
    "c": 4
}

For an array, it would work the same way - effectively acting as multiple ADD_ARRAY_ELEMENT to the end of the array. Functionally, it is identical to using IMPORT on a file holding the contents - removing the need to create a second file holding data to patch in, and also removing the need for multiple SET_KEY and ADD_ARRAY_ELEMENT patchsteps.

 

As for the version display, it simply just adds a 'v' to the beginning of the version string. Probably not the more important part of this PR, but it seemed like a waste to do a whole PR over just that. image