summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua/dungeon.lua
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/dat/clua/dungeon.lua')
-rw-r--r--crawl-ref/source/dat/clua/dungeon.lua33
1 files changed, 32 insertions, 1 deletions
diff --git a/crawl-ref/source/dat/clua/dungeon.lua b/crawl-ref/source/dat/clua/dungeon.lua
index 0a11bdd330..4359733855 100644
--- a/crawl-ref/source/dat/clua/dungeon.lua
+++ b/crawl-ref/source/dat/clua/dungeon.lua
@@ -182,6 +182,16 @@ function dgn.fnum_map(map)
return fnmap
end
+-- Given a list of feature names, returns a dictionary mapping feature
+-- numbers to true.
+function dgn.feature_number_set(feature_names)
+ local dict = { }
+ for _, name in ipairs(feature_names) do
+ dict[dgn.fnum(name)] = true
+ end
+ return dict
+end
+
-- Replaces all features matching
function dgn.replace_feat(rmap)
local cmap = dgn.fnum_map(rmap)
@@ -197,6 +207,27 @@ function dgn.replace_feat(rmap)
end
end
+function dgn.feature_set_fn(...)
+ local chosen_features = dgn.feature_number_set({ ... })
+ return function (fnum)
+ return chosen_features[fnum]
+ end
+end
+
+-- Finds all points in the map satisfying the supplied predicate.
+function dgn.find_points(predicate)
+ local points = { }
+ for x = 0, dgn.GXM - 1 do
+ for y = 0, dgn.GYM - 1 do
+ local p = dgn.point(x, y)
+ if predicate(p) then
+ table.insert(points, p)
+ end
+ end
+ end
+ return points
+end
+
-- Returns a function that returns true if the point specified is
-- travel-passable and is not one of the features specified.
function dgn.passable_excluding(...)
@@ -395,7 +426,7 @@ dgn.good_scrolls = [[
w:10 scroll of acquirement / scroll of acquirement q:2 w:4 /
scroll of acquirement q:3 w:1/
w:5 scroll of vorpalise weapon /
- w:5 scroll of immolation /
+ w:5 scroll of immolation /
w:5 scroll of vulnerability
]]