From 9aafa25b1237dbed8db955038df7e769be4ab2ee Mon Sep 17 00:00:00 2001 From: Spookerton <918997+Spookerton@users.noreply.github.com> Date: Tue, 21 Jan 2025 17:00:40 +0000 Subject: [PATCH] [MIRROR] add: list list_elements_of_type(list, type, strict) --- code/_helpers/lists.dm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/code/_helpers/lists.dm b/code/_helpers/lists.dm index dff483c6d15c4..17372d35ef116 100644 --- a/code/_helpers/lists.dm +++ b/code/_helpers/lists.dm @@ -107,6 +107,18 @@ instances++ return instances +/// Returns the elements of list that are of type path. If strict, disallows subtypes +/proc/list_elements_of_type(list/list, path, strict) + RETURN_TYPE(/list) + var/list/result = list() + for (var/datum/element as anything in list) + if (!istype(element, path)) + continue + if (strict && element.type != path) + continue + result += element + return result + //Removes any null entries from the list /proc/listclearnulls(list/list) if(istype(list))