Protogen Character

by Focsy

Recolorable Protogen Character with CharacterModHelper Support.

Content
1 year, 3 months ago
2.0
1.61K
Armor Environment

g Incompatibility with Metal And Stars

1 year, 9 days ago

when using Protogen Character with the Metal And Stars mod, it throws this error.

Failed to load mods: Error while loading entity prototype "character-corpse" (character-corpse): Invalid pictures index: 5, expected value in the range of 1 to 4. in property tree at ROOT.character-corpse.character-corpse Modifications: Base mod > Space Age > Metal and Stars > Protogen Character

When asking them about it, they said is was more likely this mod having the direct issue, let me know if you need any more information.

Also, love this mod, thank you so much for bringing it to 2.0

11 months ago

Thank you for the report, i will take a look in it.

11 months ago

i will take a look in it.

If everything is working as I expect, you shouldn't have to do anything: I've updated CharacterModHelper (version 2.03). When function check_my_prototypes is called in the final data stage, all armors that are available in armor_picture_mapping of only the default corpse will be added to armor_picture_mapping of the new corpse. They will be set to the index of the last picture.

Please try it out and check if it really works! I don't have SA, so I can't check with metal-and-stars myself …

23 days ago
(updated 23 days ago)

Just confirmed that with Metal and Stars (and CharacterModHelper 2.04), the issue still occurs, but is resolved by adding an armor_picture_mapping to the corpse, something like the following snippet:

PROTOCHAR.protos.corpse.armor_picture_mapping = {
    ["heavy-armor"] = 2,
    ["light-armor"] = 2,
    ["modular-armor"] = 3,
    ["power-armor"] = 3,
    ["power-armor-mk2"] = 3
}

Not entirely sure of the implementation in CharacterModHelper, but it doesn't seem like it quite resolves this issue yet. In the meanwhile, this mod could be patched by adding those lines to the end (after the PROTOCHAR.protos.corpse.pictures definition, around line 590 of data.lua).

Correction: CharacterModHelper actually does fix the issue, but because in this mod CharModHelper.check_my_prototypes(PROTOCHAR.protos) is run in data-final-fixes.lua, it runs after Metal and Stars does whatever it does to cause the issue, and so the fix is never run. The actual fix here would be to move CharModHelper.check_my_prototypes(PROTOCHAR.protos) from data-final-fixes.lua to data.lua. (Probably.) (Maybe?)

Edit: I noticed the README says to put the check_my_prototypes call in data-final-fixes.lua, so it might be that the specific check might need to be moved up to the data.lua phase.

10 days ago

Edit: I noticed the README says to put the check_my_prototypes call in data-final-fixes.lua, so it might be that the specific check might need to be moved up to the data.lua phase.

We can't move the call to check_my_prototypes to the data stage because that's the stage where other mods may create and modify things. We should wait until data-updates at least; but there may still be mods loaded after us that make changes to the default character. It is therefore necessary to call the function in data-final-fixes. However, it may be possible to run the armor-fix also in data-updates. I'll have to check if there is a way to do this without changes on the side of the character mods.

10 days ago
(updated 10 days ago)

So I did look into it a bit more, and came to the conclusion that I have no idea what's causing it anymore. (Maybe a conflict with !skins?) But I was able to fix it by putting this in data-final-fixes.lua:

for corpse_name, corpse in pairs(data.raw["character-corpse"]) do
    if corpse and corpse.armor_picture_mapping and corpse.pictures then
        local num_pictures = #corpse.pictures
        for armor_name, index in pairs(corpse.armor_picture_mapping or {}) do
            if index > num_pictures then
                -- limit index to size of pictures array
                corpse.armor_picture_mapping[armor_name] = num_pictures
            end
        end
    end
end

So you might be able to put a version of this check somewhere in check_my_prototypes to fix it, although iirc the specific error has to do with the base character-corpse having the extra pictures index added by metal-and-stars that character mod pictures arrays don't have, so it might need to be somewhere meant to check the actual corpse that CharModHelper.apply_properties(corpse, prototype_data.corpse) creates.

New response