Quick note: I don't have a lot of free time due to the ongoing war(s) so I may not be quick to respond, but I really love your mod, and all the other character mods that you've made possible/easier :3
Also I'm not super good with words so the following may not be organized super well or make a lot of sense, sorry...
Disabling either line 136 (table.insert) OR line 137 (setting .mech-armor
to the length of .pictures
) allows the game to load without erroring, and even allows starting a new game. I haven't tested all/any of metal-and-stars
's gameplay, but dying also functions normally. I believe this is due to the fact that the value of .armor_picture_mapping
.mech-armor
that CMH copied to its characters' corpses no longer exceeds the length of the new character corpses' .pictures
array.
So I made a small change to your CharModHelper.create_prototypes
function:
local corpse = table.deepcopy(data.raw["character-corpse"]["character-corpse"])
CharModHelper.apply_properties(corpse, prototype_data.corpse)
+ prototype_data.corpse.armor_picture_mapping = table.deepcopy(corpse.armor_picture_mapping)
data:extend({corpse})
This stopped the error and allowed me to use mini-me
, the Protogen character, and the Wickerbeast character, but will break any characters that define their own .armor_picture_mapping
arrays (currently, only the imaginary one I just made as far as I know). I'm not necessarily a huge fan of the idea of inserting extra entries into the corpes' pictures array just to match the length of the character corpse generated outside of CMH characters, because semantically that doesn't make a lot of sense. The .armor_picture_mapping
for each character probably needs to be stored when they call CharModHelper.create_prototypes
...
To ease my concern with the currently-hypothetical case where a character defines their own .armor_picture_mapping
, I think an if
might help...
local corpse = table.deepcopy(data.raw["character-corpse"]["character-corpse"])
CharModHelper.apply_properties(corpse, prototype_data.corpse)
if prototype_data.corpse.armor_picture_mapping == nil then
prototype_data.corpse.armor_picture_mapping = table.deepcopy(corpse.armor_picture_mapping)
end
data:extend({corpse})
CMH.created_msg(corpse)
Seems to work for me! Dying with mech-armor
equiped also functions without errors.