LuaSurface.create_entity{type='character-corpse', armor_picture_mapping=???}
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
LuaSurface.create_entity{type='character-corpse', armor_picture_mapping=???}
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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: LuaSurface.create_entity{type='character-corpse', armor_picture_mapping=???}
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.
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?
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"}