Merge pull request #17915 from tgstation/RemieRichards-lists

Adds a DEFAULTPICK() macro, updates an old list helper
This commit is contained in:
oranges
2016-05-26 01:39:26 +12:00
+4 -7
View File
@@ -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)