Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: A proposal to simplify cross-mod compatibility and integration  (Read 1375 times)

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
A proposal to simplify cross-mod compatibility and integration
« on: February 11, 2021, 01:20:46 AM »

   With the rise of so many mods requiring "whitelists" and "blacklists" that are often scattered around with random names, I've been mulling about using the opportunity of the 0.95 update to promote the use of a single shared data/config/modSettings.json file to manage most simple mod parameters, those required to make mods integrated with each-other in particular, plus a shared data/config/modFiles folder to keep all dedicated files such as CSVs and other long config files in a single convenient place.

This would allow two things:

   Making mod inter-compatibility easier to manage since you wouldn't have to look around what needs to be done and how. You would only have to open someone else's setting file and would immediately know all the required parameters. MagicLib can also include a blank file too as a starting point reference. Furthermore the modding wiki now has a dedicated page for modders to document the integration requirements of their mod. Given the amount of "whitelists" that are the same for many mods, having a single file would prevent mistakes or missing a list somewhere.

   It would also allow people to easily make a "setting mod" that would keep their adjustments unaltered through mod updates. While it is possible to do now, it is quite a chore to setup.

Examples of files that could be merged:
Code
mining_weapons (Nexerelin)
corvus_capitals (Nexerelin)
corvus_spawnpoints (Nexerelin)
Prism_faction_whitelist (Nexerelin/Scy)
Prism_ship_blacklist (Nexerelin/Scy)
Prism_weapons_blacklist (Nexerelin/Scy)
faction_rep_change_blacklist (ruthless sector)
faction_rep_change_whitelist (ruthless sector)
MagicInterference
Allowed_factions (newBegining)
Plague files (Seeker)
printing_whitelist (indevo)
reverse_engineering_whitelist (indevo)
no_self_destruct (graphicLib)
version_files (the one from config, not the version file at the root)

Example of files that could be moved to a shared folder:
Code
factionConfigurations (starship_legend)
rare_flagships (vayra's sector)
Graphiclib maps and lights files (already possible using custom paths when called)
MagicTrails
customStarts (Nexerelin)

And since I'm not one to ask for more work from other modders, the latest MagicLib update now includes all the tools required to allow even the less code savvy among us to use that shared file without any hassle. MagicSettings functions can fetch the following data from modSettings.json:

Code: java
boolean getBoolean(String modId, String id)
String getString(String modId, String id)
float getFloat(String modId, String id)
Integer getInteger(String modId, String id)
Color getColorRGB(String modId, String id)
Color getColorRGBA(String modId, String id)
List<String> getList(String modId, String id)
Map<String,Float> getFloatMap(String modId, String id)
Map<String,String> getStringMap(String modId, String id)
Map<String,Color> getColorMap(String modId, String id)

Together this allows to have an easily manageable setting file, for example this one that will be present in the next Diable Avionics update would previously had been scattered into 7(!) different files:
Code: json
{   
    #DIABLE AVIONICS SETTINGS FILE
    "diableavionics":{

        "missile_resist_derecho": [
               # Lists missiles id that should loose guidance but not get flamed out by the Derecho ECM system
            "diableavionics_srab_shot",
        ],

        "missile_immune_derecho": [
               # Lists missiles id that should not get affected at all by the Derecho ECM system
               # please be mindful to not break player expectations, only very special projectiles should be immune
               # Such as phased missiles or "smart" bullets
            "ora_echoesS",
            "ora_invocationS",
            "ora_callingS",
            "SCY_phasedS",
            "SKR_can",
            "SKR_drill_shot",
        ],

        "gantry_refitMult" : 0.5,
           # Refit time bonus for wanzer installed on a ship with the Wanzer Gantry hullmod. Default 0.5
        "gantry_depletionPercent" : 20,
           # Fighter replacement rate depletion malus per wanzer wing installed on a ship with the Wanzer Gantry hullmod. Default 20

        "wanzers": [
               # Lists "wanzer" wings that are affected by the "Wanzer gantry" hullmod
            "diableavionics_frost_wing",
            "diableavionics_strife_wing",
            "diableavionics_hoar_wing",
            "diableavionics_warlust_wing",
            "diableavionics_avalanche_wing",
            "diableavionics_valiant_wing",
            "diableavionics_raven_wing",
            "diableavionics_blizzaia_wing",
            "diableavionics_zephyr_wing",
            "diableavionics_vortex_wing",
        ],
    },

    #MODS INTEGRATION
    "SCY":{
        "amity_factionWhitelist":[
               # Lists factions that should have their known ships and weapons sold in Amity's Freeport discount trader.
            "diableavionics",
        ],
        "amity_blacklist":[
               # Lists ships, weapons and wings ids that should be culled from Amity's Freeport discount trader.
               # Consider that tier 3 weapons/wings and ships above 5/10/14/23 FP are already culled from that store automatically.
        ],
    },
    "MagicLib":{
        "interferences_weapons":{
            # List weapons that can "interfere" with each-other reducing the ship's dissipation when several are mounted on the same hull.
        },
    },
}

And very simple code to fetch and merge that data across all mods:
Code: java
public class DAModPlugin extends BaseModPlugin {
    public static List<String> DERECHO_RESIST = new ArrayList<>();
    public static List<String> DERECHO_IMMUNE = new ArrayList<>();
    public static List<String> WANZERS = new ArrayList<>();
    public static float GANTRY_TIME_MULT = 1, GANTRY_DEPLETION_PERCENT = 0;
   
    @Override
    public void onApplicationLoad() throws ClassNotFoundException { 
        //modSettings loading:
        DERECHO_RESIST = MagicSettings.getList("diableavionics", "missile_resist_derecho");       
        DERECHO_IMMUNE = MagicSettings.getList("diableavionics", "missile_immune_derecho");               
        WANZERS = MagicSettings.getList("diableavionics", "wanzers");
        GANTRY_TIME_MULT = MagicSettings.getFloat("diableavionics", "gantry_refitMult");
        GANTRY_DEPLETION_PERCENT = MagicSettings.getFloat("diableavionics", "gantry_depletionPercent");     
    }
}

You can find more detailed documentation about using MagicLib to simplify cross-mods integrations in the dedicated wiki page.

Of course this is just a suggestion, but if a few big modders decide to follow me with that idea, I hope it would make everyone's life a bit easier. If anything, I am migrating all of my own mods to use this setup and it is both easy and cleaner than before.




TLDR:
 - The magicSettings functions in MagicLib allow modders to easily access a shared data/config/modSettings.json file that can be used as a unified solution to integrate mods with each-others.

 - MagicLib will try to provide a thorough blank modSettings.json sample file with each update.

 - Modders that will use the shared modSettings.json file and want their mod's settings to be added to MagicLib's sample file can post them in MagicLib's thread.

 - Modders can document their inter-mod compatibility requirements, regardless of their usage of modSettings or not, on this wiki page.
« Last Edit: February 11, 2021, 08:09:14 AM by Tartiflette »
Logged
 

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7214
  • Harpoon Affectionado
    • View Profile
Re: A proposal to simplify cross-mod compatibility and integration
« Reply #1 on: February 11, 2021, 10:14:55 AM »

Oh, this looks really useful!

As an example, say I added a mod with a special effects missile I didn't want the Derecho to completely effect. Would I then put as part of my mods data/config/modSettings.json

Code: json
{   
    "diableavionics":{
        "missile_resist_derecho": [
            "myMod_weird_missile",
        ]
    }
}

And then, on application load, DA would see this in the merged file and then act appropriately? Thats really nice. I suppose this also lets other mods do things like add their own Wanzer fighters that interact correctly with all the hullmods.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: A proposal to simplify cross-mod compatibility and integration
« Reply #2 on: February 11, 2021, 10:29:05 AM »

It was already possible to do so, but this proposed shared file coupled with the new MagicLib functions makes it really easy to implement, instead of having to track down and manage dozens of files scattered around.

So far the reception from modders has been pretty positive so I'm hopeful it will gain steam.
Logged
 

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7214
  • Harpoon Affectionado
    • View Profile
Re: A proposal to simplify cross-mod compatibility and integration
« Reply #3 on: February 11, 2021, 10:50:31 AM »

Right, ease of use is extremely, well, useful! It helps that MagicLib already has so much useful stuff in it and most people playing with mods have it on all the time anyways.
Logged