mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 08:08:49 +01:00
Merge pull request #17915 from tgstation/RemieRichards-lists
Adds a DEFAULTPICK() macro, updates an old list helper
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user