diff options
author | Steve Melenchuk <smelenchuk@gmail.com> | 2012-07-08 12:29:15 -0600 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2012-07-08 14:54:15 -0400 |
commit | 5e44e2c1af8e600b374209325abfe6c384d8d09c (patch) | |
tree | b23ea199482ea4a4cd8583afa7eda02411643bb3 /crawl-ref/source/l_dgnlvl.cc | |
parent | 234122f292131efb149fc5ecdccdad131b63870d (diff) | |
download | crawl-ref-5e44e2c1af8e600b374209325abfe6c384d8d09c.tar.gz crawl-ref-5e44e2c1af8e600b374209325abfe6c384d8d09c.zip |
New Lua function: dgn.br_exists().
This function reports if a specific branch exists in the game; it's most
useful for checking if specific Lair branches have been generated.
Diffstat (limited to 'crawl-ref/source/l_dgnlvl.cc')
-rw-r--r-- | crawl-ref/source/l_dgnlvl.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crawl-ref/source/l_dgnlvl.cc b/crawl-ref/source/l_dgnlvl.cc index a8b6a88e3c..ceb461c2a2 100644 --- a/crawl-ref/source/l_dgnlvl.cc +++ b/crawl-ref/source/l_dgnlvl.cc @@ -45,6 +45,25 @@ LUAFN(dgn_br_depth) PLUARET(number, brdepth[brn]); } +LUAFN(dgn_br_exists) +{ + bool exists = false; + branch_type brn = you.where_are_you; + if (lua_gettop(ls) == 1) + { + const char *branch_name = luaL_checkstring(ls, 1); + brn = str_to_branch(branch_name); + if (brn == NUM_BRANCHES) + luaL_argerror(ls, 1, "No such branch"); + } + + if (branches[brn].parent_branch == NUM_BRANCHES + || startdepth[brn] != -1) + exists = true; + + PLUARET(boolean, exists); +} + static void _push_level_id(lua_State *ls, const level_id &lid) { // [ds] Should really set up a metatable to delete (FIXME). @@ -102,6 +121,7 @@ const struct luaL_reg dgn_level_dlib[] = { "br_has_uniques", dgn_br_has_uniques }, { "br_parent_branch", dgn_br_parent_branch }, { "br_depth", dgn_br_depth }, +{ "br_exists", dgn_br_exists }, { "level_id", dgn_level_id }, { "level_name", dgn_level_name }, |