diff options
Diffstat (limited to 'crawl-ref/source/dat/clua/util.lua')
-rw-r--r-- | crawl-ref/source/dat/clua/util.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crawl-ref/source/dat/clua/util.lua b/crawl-ref/source/dat/clua/util.lua index fa78b189aa..4894f1fc67 100644 --- a/crawl-ref/source/dat/clua/util.lua +++ b/crawl-ref/source/dat/clua/util.lua @@ -190,6 +190,15 @@ function util.exists(list, pred) return false end +function util.contains(haystack, needle) + for _, value in ipairs(haystack) do + if value == needle then + return true + end + end + return false +end + function util.random_from(list) return list[ crawl.random2(#list) + 1 ] end |