diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index afc07638e4b..452d2027b5e 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -238,13 +238,7 @@ return r // Returns the key based on the index -/proc/get_key_by_index(list/L, index) - var/i = 1 - for(var/key in L) - if(index == i) - return key - i++ - return null +#define KEYBYINDEX(L, index) (((index <= L:len) && (index > 0)) ? L[index] : null) /proc/count_by_type(list/L, type) var/i = 0 @@ -365,3 +359,6 @@ for(var/i = 1 to l.len) if(islist(.[i])) .[i] = .(.[i]) + +//Picks from the list, with some safeties, and returns the "default" arg if it fails +#define DEFAULTPICK(L, default) ((istype(L, /list) && L:len) ? pick(L) : default)