summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua/util.lua
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-09 01:21:44 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-09 01:47:09 +0530
commit9841ce45ea91c1ad394d706fd748ffc1fd9d9de0 (patch)
tree047cbb69276a6b8c55d9b22c1e01442a8bd7d173 /crawl-ref/source/dat/clua/util.lua
parent915b92e5527c1300fa701a31e3dcbc070b48d177 (diff)
downloadcrawl-ref-9841ce45ea91c1ad394d706fd748ffc1fd9d9de0.tar.gz
crawl-ref-9841ce45ea91c1ad394d706fd748ffc1fd9d9de0.zip
Add -script option to Crawl to run a Lua script. Scripts are similar to tests, but can be parameterised.
Add a script to generate 150 level at a named place and report on all the monsters generated there.
Diffstat (limited to 'crawl-ref/source/dat/clua/util.lua')
-rw-r--r--crawl-ref/source/dat/clua/util.lua14
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)