diff options
Diffstat (limited to 'crawl-ref/source/dat/clua/util.lua')
-rw-r--r-- | crawl-ref/source/dat/clua/util.lua | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crawl-ref/source/dat/clua/util.lua b/crawl-ref/source/dat/clua/util.lua index d6e842fa7e..8dd0b35eba 100644 --- a/crawl-ref/source/dat/clua/util.lua +++ b/crawl-ref/source/dat/clua/util.lua @@ -56,7 +56,7 @@ end -- Returns a list of the keys in the given map. function util.keys(map) local keys = { } - for key, _ in pairs(ziggurat_builder_map) do + for key, _ in pairs(map) do table.insert(keys, key) end return keys @@ -65,12 +65,22 @@ end -- Returns a list of the values in the given map. function util.values(map) local values = { } - for _, value in pairs(ziggurat_builder_map) do + for _, value in pairs(map) do table.insert(values, value) end return values end +-- Returns a list of lists built from the given map, each sublist being +-- in the form { key, value } for each key-value pair in the map. +function util.pairs(map) + local mappairs = { } + for key, value in pairs(map) do + table.insert(mappairs, { key, value }) + end + return mappairs +end + -- Creates a string of the elements in list joined by separator. function util.join(sep, list) return table.concat(list, sep) |