Character mod helper

by Pi-C

If your mod lets players use a character that looks differently, you'll have to decide whether you must overwrite the default character. This mod will help you with this decision, and make it really simple to overwrite the default or update the new prototypes in a safe way.

Internal
8 days ago
1.1 - 2.0
72.8K
Character

b [Fixed?] Incompatibility with New Gear Girl, UFP, and Metal Stars

I've been trying to track down the origin of an incompatibility between New Gear Girl (https://mods.factorio.com/mod/NewGirlCharacter-port), and several other mods.

Do you have any ideas about how to fix this, or even why they would affect each other?

Load order #1 * Space Age - 2.0.66 * Metal and Stars - 0.1.17 * New Gear Girl Character 2.0 - 1.0.4
(and their dependencies)

3.748 Error ModManager.cpp:1758: 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 › New Gear Girl Character 2.0

Load order #2 * Space Age 2.0.66 * UFP: Ultimate Fusion Power Fixed - 1.0.18 * New Gear Girl Character 2.0 - 1.0.4
(and their dependencies)

3.037 Error ModManager.cpp:1758: 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 › UFP: Ultimate Fusion Power Fixed › New Gear Girl Character 2.0

3 months ago
(updated 3 months ago)

Im the owner of UFP. Edit: the problem is on this side i guess. Edit 2: fixed on this side.

29 days ago

Please check out version 2.0.5!

@ VVVVVVEmersonFisioVVVVVV: Thanks for your fix! But there still was the problem with "Metal and Stars", which should be fixed with the latest update.

29 days ago

I always thought it was how FuryoftheStars ported gear girl or something, but i guess it was pi-c all along >.>

29 days ago

Update to my issue. I removed the hacked-in fourth entry in NEWGEARGIRL.corpse.pictures, and the game crashes saying

Failed to load mods: Error while loading entity prototype "character-corpse" (character-corpse): Invalid pictures index: 4, expected value in the range of 1 to 3. in property tree at ROOT.character-corpse.character-corpse
Modifications: Base mod › Space Age › New Gear Girl Character 2.0

NEWGEARGIRL.corpse.pictures = {
{
layers = {
charactergeargirl_animations.level1.dead,
charactergeargirl_animations.level1.dead_mask,
charactergeargirl_animations.level1.dead_shadow
}
},
{
layers = {
charactergeargirl_animations.level2addon.dead,
charactergeargirl_animations.level2addon.dead_mask,
charactergeargirl_animations.level1.dead_shadow
}
},
{
layers = {
charactergeargirl_animations.level3addon.dead,
charactergeargirl_animations.level3addon.dead_mask,
charactergeargirl_animations.level1.dead_shadow
}
},
}

The crash doesn't happen when the fourth entry is returned.
I am not using Metal and Stars, but am using Space Age.

NEWGEARGIRL.corpse.pictures = {
{
layers = {
charactergeargirl_animations.level1.dead,
charactergeargirl_animations.level1.dead_mask,
charactergeargirl_animations.level1.dead_shadow
}
},
{
layers = {
charactergeargirl_animations.level2addon.dead,
charactergeargirl_animations.level2addon.dead_mask,
charactergeargirl_animations.level1.dead_shadow
}
},
{
layers = {
charactergeargirl_animations.level3addon.dead,
charactergeargirl_animations.level3addon.dead_mask,
charactergeargirl_animations.level1.dead_shadow
}
},
{
layers = {
charactergeargirl_animations.level3addon.dead,
charactergeargirl_animations.level3addon.dead_mask,
charactergeargirl_animations.level1.dead_shadow
}
}
}

17 days ago

The recent update on 28/1 has broken the mechanicus skin with a similar error message as above;

Failed to load mods: Error while loading entity prototype "character-corpse" (character-corpse): Invalid pictures index: 0, expected value in the range of 1 to 1. in property tree at ROOT.character-corpse.character-corpse
Modifications: Base mod › Mechanicus (Rebuild)

I am a bit confused though, shouldn't the index range be starting at index 0? Why is there a value in the range of 1 to 1? Where is this defined in the character information?

17 days ago
(updated 17 days ago)

@tithin: Thanks for the report, I could reproduce the crash. My assumption that corpse_data.pictures would always be an array (indexed with subsequent numbers) was wrong. It should work again if you change line 121 of file images.lua from

  local last_pic = #corpse_data.pictures

to

  local last_pic = table_size(corpse_data.pictures)

This is a hotfix that will work with Mechanicus, but could cause problems with other mods. The next version will have a more elaborate check that (I hope!) will fix this bug for good.

I am a bit confused though, shouldn't the index range be starting at index 0?

In Lua, newly created arrays will start with index 1.

Why is there a value in the range of 1 to 1?

Because the table corpse_data.pictures has only one entry (with index 1) in this case; 1 is used in the error message for both first and last entry in the array (array: table indexed with consecutive numbers, starting with 1).

Where is this defined in the character information?

Check out data.raw.character[char_name].animations! Each animation in this array may have a value armors. If set, this is an array of armor names, if nil, it is for players without armor.

17 days ago

Thank you both for the fix, as well as the knowledge.

8 days ago

Update to my issue. I removed the hacked-in fourth entry in NEWGEARGIRL.corpse.pictures, and the game crashes saying

Failed to load mods: Error while loading entity prototype "character-corpse" (character-corpse): Invalid pictures index: 4, expected value in the range of 1 to 3. in property tree at ROOT.character-corpse.character-corpse

The problem was that you didn't set armor_picture_mapping in the corpse, so the data.raw["character-corpse"]["character-corpse"].armor_picture_mapping would always be used. That was OK in Factorio < 2.0 because the new character would have the same number of corpse pictures as the default character. But the default corpse can now have a varying number of pictures, depending on the presence of SA – while your character would always have 3 animations. So this could be fixed directly in the character mod.

However, I've made some changes to the way armor names are mapped to picture indexes in the new character. I hope this will fix the crash for good! Please check out version 2.0.6! :-)

8 days ago

Thank you both for the fix, as well as the knowledge.

You're welcome! Does version 2.0.6 work for you?

New response