summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/l_dgn.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-02-24 05:34:35 +0100
committerAdam Borowski <kilobyte@angband.pl>2013-02-24 05:34:35 +0100
commit65306b0f297ae9ce4a5b2a52f055a2f2482dbad2 (patch)
tree376bb1bec86026fdc5317a0299ade45d788f8ef7 /crawl-ref/source/l_dgn.cc
parentb957c737d34260acddc671a3c7bbe9cb810665c0 (diff)
parente8f008ab92473c7cc7a26b7a8504733b7c80a407 (diff)
downloadcrawl-ref-65306b0f297ae9ce4a5b2a52f055a2f2482dbad2.tar.gz
crawl-ref-65306b0f297ae9ce4a5b2a52f055a2f2482dbad2.zip
Merge branch 'master' into mon-pick
Sorry for merge commits, but rerere is pretty limited.
Diffstat (limited to 'crawl-ref/source/l_dgn.cc')
-rw-r--r--crawl-ref/source/l_dgn.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc
index 0682ddf1b9..972236ae54 100644
--- a/crawl-ref/source/l_dgn.cc
+++ b/crawl-ref/source/l_dgn.cc
@@ -1602,6 +1602,22 @@ LUAFN(_dgn_in_vault)
return 1;
}
+LUAFN(_dgn_set_map_mask)
+{
+ GETCOORD(c, 1, 2, map_bounds);
+ const int mask = lua_isnone(ls, 3) ? MMT_VAULT : lua_tointeger(ls, 3);
+ env.level_map_mask(c) |= mask;
+ return 1;
+}
+
+LUAFN(_dgn_unset_map_mask)
+{
+ GETCOORD(c, 1, 2, map_bounds);
+ const int mask = lua_isnone(ls, 3) ? MMT_VAULT : lua_tointeger(ls, 3);
+ env.level_map_mask(c) &= ~mask;
+ return 1;
+}
+
LUAFN(_dgn_map_parameters)
{
return clua_stringtable(ls, map_parameters);
@@ -1761,6 +1777,31 @@ LUAFN(_dgn_reuse_map)
return 0;
}
+// dgn.inspect_map(vplace,x,y)
+//
+// You must first have resolved a map to get the vault_placement, using
+// dgn.resolve_map(..). This function will then inspect a coord on that map
+// where <0,0> is the top-left cell and tell you the feature type. This will
+// respect all KFEAT and other map directives; and SUBST and other
+// transformations will have already taken place during resolve_map.
+LUAFN(_dgn_inspect_map)
+{
+ if (!lua_isuserdata(ls, 1))
+ luaL_argerror(ls, 1, "Expected vault_placement");
+
+ vault_placement &vp(*static_cast<vault_placement*>(lua_touserdata(ls, 1)));
+
+ // Not using the COORDS macro because it checks against in_bounds which will fail 0,0 (!)
+ coord_def c;
+ c.x = luaL_checkint(ls, 2);
+ c.y = luaL_checkint(ls, 3);
+
+ lua_pushnumber(ls, vp.feature_at(c));
+ lua_pushboolean(ls, vp.is_exit(c));
+ lua_pushboolean(ls, vp.is_space(c));
+ return 3;
+}
+
LUAWRAP(_dgn_reset_level, dgn_reset_level())
LUAFN(dgn_fill_grd_area)
@@ -1881,7 +1922,10 @@ const struct luaL_reg dgn_dlib[] =
{ "place_map", _dgn_place_map },
{ "reuse_map", _dgn_reuse_map },
{ "resolve_map", _dgn_resolve_map },
+{ "inspect_map", _dgn_inspect_map },
{ "in_vault", _dgn_in_vault },
+{ "set_map_mask", _dgn_set_map_mask },
+{ "unset_map_mask", _dgn_unset_map_mask },
{ "map_parameters", _dgn_map_parameters },