From 9641ea217929805f5e1608f1a8bc5409cb3ae47d Mon Sep 17 00:00:00 2001 From: Kirazy <35714562+kirazy@users.noreply.github.com> Date: Mon, 6 Jul 2020 01:33:15 -0700 Subject: [PATCH] Add function to rescale remnants --- changelog.txt | 4 +++- prototypes/functions.lua | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index e106cf1..3927ac2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ --------------------------------------------------------------------------------------------------- Version: 0.00.8 -Date: 2020.06.XX +Date: 2020.07.06 + Features: + - Added function "rescale_remnant" --------------------------------------------------------------------------------------------------- Version: 0.00.7 Date: 2020.06.24 diff --git a/prototypes/functions.lua b/prototypes/functions.lua index 7ebdc3c..0325b9c 100644 --- a/prototypes/functions.lua +++ b/prototypes/functions.lua @@ -822,4 +822,26 @@ function reskins.lib.setting(name) end return startup_setting +end + +-- Rescale remnant entities +function reskins.lib.rescale_remnant(entity, scale) + -- Check the entity exists + if not entity then return end + + -- Fetch remnant + local remnant_name = entity.corpse + + -- Create, rescale, and assign rescaled remnant + if remnant_name then + local remnant = data.raw.corpse[remnant_name] + + if remnant then + rescaled_remnant = util.copy(remnant) + rescaled_remnant.name = "rescaled-"..rescaled_remnant.name + reskins.lib.rescale_entity(rescaled_remnant, scale) + data:extend({rescaled_remnant}) + entity.corpse = rescaled_remnant.name + end + end end \ No newline at end of file