TL;DRIdea for an easy way to support multiple character skins in one game
What?One of my mods comes with a character selector that allows you to change your character during the game. It works, but there is one big flaw: Most mods that provide new character skins ("skin mods" from now on) assume that the mod is active because their character should be used. Currently, vanilla does the same thing. There's only one character in the game (data.raw.character.character), so this is the character that the game will always use.
In order to make sure that their character will be used, skin mods have to overwrite data.raw.character.character with their own! This doesn't really matter if only one such mod is used. But if you'd ever choose to have two skin mods active at the same time, only the one that's loaded last will be usable because that is the last mod that overwrote the default character. (Things may even get worse if the last mod has less properties set than the previous one, and doesn't clear the prototype before overwriting it!)
Why?There are mods about that provide new character skins, so there must be players who'd like to try a game with a differently looking character.
As author of a character selector mod, I've tried to convince skin mod authors to follow this procedure:
- Define your character in data.lua. Don't overwrite the default character yet, but give it an alternative name! The name should follow a common pattern so that character selector mods can filter out unwanted characters.
- Do nothing in data-updates.lua! This way, character selector mods will get a chance to compile a list of all available characters and do whatever they need to do.
- In data-final-fixes.lua, check if a known character-selector mod is active! If there is, do nothing. Otherwise, overwrite the default character and hope that no other skin mod is loaded after yours!
The procedure outlined above would make sure that my mod (and other character selector mods) can access different modded characters, if available, as well as the default character. It also guarantees skin mod authors that their character will be used
How about this? There's a table where skin mod authors can register their characters. (Characters may be created for different reasons -- e.g. as dummies that are placed in vehicles, see AAI Programmable Vehicles and Autodrive. Giving skin mods the chance to register their characters would filter out characters that are not meant to be used by players.) The table is part of vanilla, so it can be accessed by skin mods and character selector mods during the data and during the control stage. If that table is empty (or contains no name of a valid character entity) at the end of data-final-fixes.lua, just use the default character. If the table contains one valid entry, let Factorio assume that the player wants to use that character and activate it. If the table contains several valid entries, assume that a character-selector mod is active as well
Would you mind adding this? I mean, a vanilla character selector would be great