Starsector 0.97a is out! (02/02/24); New blog post: Codex Overhaul (05/11/24)
List<String> theVariants = Global.getSettings().getAllVariantIds(); for(String variantID : theVariants){ ShipVariantAPI thisVariant = Global.getSettings().getVariant(variantID); List<WeaponGroupSpec> groupSpec = thisVariant.getWeaponGroups(); if(groupSpec.size() > 4){ Global.getLogger(SS_Al_ModPlugin.class).log(Level.ERROR,"ERROR: Variant: " + variantID + " has more than allowed weapon groups."); } else { Global.getLogger(SS_Al_ModPlugin.class).log(Level.ERROR,"The Variant: " + variantID + " is fine."); } }
{ "displayName": "Assault", "fluxCapacitors": 5, "fluxVents": 29, "goalVariant": true, "hullId": "dominator", "hullMods": [ "heavyarmor", "solar_shielding", "stabilizedshieldemitter", "targetingunit", "autorepair" ], "permaMods": [], "variantId": "dominator_Assault", "weaponGroups": [ { "autofire": false, "mode": "LINKED", "weapons": { "WS 012": "mark9", "WS 013": "hephag" } }, { "autofire": false, "mode": "ALTERNATING", "weapons": { "WS 014": "typhoon", "WS 015": "typhoon", "WS 016": "typhoon" } }, { "autofire": true, "mode": "LINKED", "weapons": { "WS 010": "flak", "WS 011": "flak" } }, { "autofire": true, "mode": "LINKED", "weapons": { "WS 001": "vulcan", "WS 002": "vulcan", "WS 003": "vulcan", "WS 004": "vulcan", "WS 005": "vulcan", "WS 006": "vulcan", "WS 007": "vulcan", "WS 008": "vulcan", "WS 009": "vulcan" } } ], }
The alternative is to use replace, but I don't think that allows for wildcards or path-level wildcards, and it's a few hundred unique strings. Ouch.
Hmm - SettingsAPI: List<String> getAllVariantIds(); and go from there? But this doesn't look like a "more than 5 weapon groups" issue, I don't think, at least based on that stack trace. This is more likely to be an invalid slot ID in a variant.
Oh, now that's freakishly useful-looking for doing serious hackery, lol. Thank you!The problem arising though is: without explicit control over mod loading orders, this might not be a plays-well-with-others approach.The current idea here is that JSON will now allow append operations and proper inheritance. That's actually really good, in a variety of cases, like when you just want to add <some little thing> to <some bit of core game data>.The bad side of this is when the expected behavior is that we're replacing X with Y, rather than appending and arriving at XY. This stuff with variants is just another case of the same issue with the appending concept; while append is super-great for some things, in this case, it's crash-city just by including a few .variant files. Dunno what JSON handler Alex is using; this seems like something where maybe we could use <some special characters> to tell the game to Append This To Inherited Data or Replace This JSONObject / JSONArray With My Version.
I am definitely not certain, but it seems to happen especially if weapon slots between the base game ship and a mod ship share roughly the same location in the ship file. Or at the time I thought it could be that sharing the same weaponslot id doesn't override with the mod loaded ship's definition of that id, and the game can't decide which one to use when it uses a variant to populate that slot with a weapon.The other slot is sill there in the editor, though, so I guess it is technically merged. It just can't equip a weapon at the same time as the other slot occupying the same space. It will override whatever was in the other slot if you select a weapon for the unused slot. The only time I got to see that behavior, though, was if it didn't crash upon viewing the variant in the first place.