Skip to content

Commit

Permalink
[MIRROR] add: list list_elements_of_type(list, type, strict)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spookerton authored and LordNest committed Feb 12, 2025
1 parent 0430321 commit 60826f3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions code/_helpers/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 60826f3

Please sign in to comment.