Page 1 of 1

LuaSurface.create_entity{type='character-corpse', armor_picture_mapping=???}

Posted: Sat Sep 11, 2021 4:50 pm
by eradicator
Character corpse prototypes in data stage can define an armor_picture_mapping, but at runtime I see no way to either read this or spawn a corpse with a specific armor mapping. My mod Eradicator's Character Additions would look a bit nicer if I could pass i.e. the name of an armor prototype to create_entity when spawning a corpse. Or alternatively to be able to write an armor name directly to a corpse LuaEntity similarly to how graphics_variations works.

Re: LuaSurface.create_entity{type='character-corpse', armor_picture_mapping=???}

Posted: Thu Oct 21, 2021 9:21 am
by boskid
How CharacterCorpsePrototype::armor_picture_mapping works: it is a mapping from an ItemID to an armor index. Game checks entire character corpse inventory and if it finds an item which has a record in the armor_picture_mappings, it takes its value. Highest value found during the corpse inventory scan is used to select what should be drawn. If you want to change the look of a corpse you can insert proper items into the character corpse inventory.

This example will create a corpse with armor index 3 due to power-armor-mk2 in the inventory.

Code: Select all

/c game.player.surface.create_entity({name="character-corpse",position={0,0},inventory_size=10,force="player"}).get_inventory(defines.inventory.character_corpse).insert{name="power-armor-mk2"}
Is that enough for your use case or do you want an "override" which will force a specific armor variation index without a need of a specific item in the inventory?