summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/l_crawl.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-08-01 02:04:41 -0400
committerNeil Moore <neil@s-z.org>2014-08-01 02:04:51 -0400
commitbf02086bd654aed8d719b933843d381eb93dcd43 (patch)
tree058592f1e5f9b6e0ab3aebe55a7d8565c72ba9d2 /crawl-ref/source/l_crawl.cc
parent838f727e50f8fe6fd7f906f2bfb0d120ab0ac62a (diff)
downloadcrawl-ref-bf02086bd654aed8d719b933843d381eb93dcd43.tar.gz
crawl-ref-bf02086bd654aed8d719b933843d381eb93dcd43.zip
Make is_unavailable_god available to dlua.
As crawl.unavailable_god("Jiyva")
Diffstat (limited to 'crawl-ref/source/l_crawl.cc')
-rw-r--r--crawl-ref/source/l_crawl.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc
index 4e21da7e09..88fd44aea4 100644
--- a/crawl-ref/source/l_crawl.cc
+++ b/crawl-ref/source/l_crawl.cc
@@ -1151,6 +1151,25 @@ static string _crawl_make_name(lua_State *ls)
LUARET1(crawl_make_name, string, _crawl_make_name(ls).c_str())
+// FIXME: factor out the duplicated code in the next two functions.
+LUAFN(_crawl_unavailable_god)
+{
+ const char *god_name = luaL_checkstring(ls, 1);
+ if (!god_name)
+ {
+ string err = "unavailable_god requires a god!";
+ return luaL_argerror(ls, 1, err.c_str());
+ }
+ god_type god = str_to_god(god_name);
+ if (god == GOD_NO_GOD)
+ {
+ string err = make_stringf("'%s' matches no god.", god_name);
+ return luaL_argerror(ls, 1, err.c_str());
+ }
+ lua_pushboolean(ls, is_unavailable_god(god));
+ return 1;
+}
+
static int _crawl_god_speaks(lua_State *ls)
{
if (!crawl_state.io_inited)
@@ -1230,6 +1249,7 @@ static const struct luaL_reg crawl_dlib[] =
{ "print_hint", crawl_print_hint },
{ "mark_game_won", _crawl_mark_game_won },
{ "hints_type", crawl_hints_type },
+{ "unavailable_god", _crawl_unavailable_god },
{ NULL, NULL }
};