From 2e473b758e26f8aa9bf64f67c6660ba3fe423bbb Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 21 May 2021 00:27:18 +0200 Subject: [PATCH] [MIRROR] makes LoadComponent() a macro like AddComponent() is so it supports named arguments (#5802) * makes LoadComponent() a macro like AddComponent() is so it supports named arguments * Update miscellaneous.dm Co-authored-by: Kylerace Co-authored-by: Gandalf --- code/__DEFINES/dcs/helpers.dm | 3 +++ code/datums/components/_component.dm | 6 +++--- code/datums/materials/basemats.dm | 2 +- code/modules/clothing/shoes/miscellaneous.dm | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/dcs/helpers.dm b/code/__DEFINES/dcs/helpers.dm index ba2b9a704a3..a0080d7266e 100644 --- a/code/__DEFINES/dcs/helpers.dm +++ b/code/__DEFINES/dcs/helpers.dm @@ -21,3 +21,6 @@ /// A wrapper for _AddComponent that allows us to pretend we're using normal named arguments #define AddComponent(arguments...) _AddComponent(list(##arguments)) + +/// A wrapper for _LoadComponent that allows us to pretend we're using normal named arguments +#define LoadComponent(arguments...) _LoadComponent(list(##arguments)) diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 9c66c33c8e4..c2e5a24fcab 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -473,10 +473,10 @@ * * component_type The typepath of the component to create or return * * ... additional arguments to be passed when creating the component if it does not exist */ -/datum/proc/LoadComponent(component_type, ...) - . = GetComponent(component_type) +/datum/proc/_LoadComponent(list/arguments) + . = GetComponent(arguments[1]) if(!.) - return _AddComponent(args) + return _AddComponent(arguments) /** * Removes the component from parent, ends up with a null parent diff --git a/code/datums/materials/basemats.dm b/code/datums/materials/basemats.dm index bf6c3f5f548..b4490c66843 100644 --- a/code/datums/materials/basemats.dm +++ b/code/datums/materials/basemats.dm @@ -161,7 +161,7 @@ Unless you know what you're doing, only use the first three numbers. They're in /datum/material/bananium/on_applied(atom/source, amount, material_flags) . = ..() - source.LoadComponent(/datum/component/squeak, list('sound/items/bikehorn.ogg'=1), 50, 0, 0, 0, 0, 20, 0) + source.LoadComponent(/datum/component/squeak, list('sound/items/bikehorn.ogg'=1), 50, falloff_exponent = 20) source.AddComponent(/datum/component/slippery, min(amount / 10, 80)) /datum/material/bananium/on_removed(atom/source, amount, material_flags) diff --git a/code/modules/clothing/shoes/miscellaneous.dm b/code/modules/clothing/shoes/miscellaneous.dm index fbcab2fcfb0..eaea0078cdf 100644 --- a/code/modules/clothing/shoes/miscellaneous.dm +++ b/code/modules/clothing/shoes/miscellaneous.dm @@ -104,7 +104,7 @@ /obj/item/clothing/shoes/clown_shoes/Initialize() . = ..() - LoadComponent(/datum/component/squeak, list('sound/effects/clownstep1.ogg'=1,'sound/effects/clownstep2.ogg'=1), 50, 0, 0, 0, 0, 20, 0) //die off quick please + LoadComponent(/datum/component/squeak, list('sound/effects/clownstep1.ogg'=1,'sound/effects/clownstep2.ogg'=1), 50, falloff_exponent = 20) //die off quick please //AddElement(/datum/element/swabable, CELL_LINE_TABLE_CLOWN, CELL_VIRUS_TABLE_GENERIC, rand(2,3), 0) SKYRAT EDIT REMOVAL /obj/item/clothing/shoes/clown_shoes/equipped(mob/user, slot)