summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/l_dgngrd.cc
diff options
context:
space:
mode:
authorPete Hurst <pete@streamuniverse.tv>2013-05-05 06:54:23 +0100
committerPete Hurst <pete@streamuniverse.tv>2013-05-05 06:54:23 +0100
commit52a7a68afd6919799c384a14b2fedf3caebed887 (patch)
tree7e0a385225fd0fac844d39a9b8c18ddd9723f4ec /crawl-ref/source/l_dgngrd.cc
parent81829c9d51b11be8d7628b1d9880a1c0407274c9 (diff)
downloadcrawl-ref-52a7a68afd6919799c384a14b2fedf3caebed887.tar.gz
crawl-ref-52a7a68afd6919799c384a14b2fedf3caebed887.zip
Allow specifying layout_chaotic_city material type from Lua
Previously this couldn't be done so materials would be random in Dis.
Diffstat (limited to 'crawl-ref/source/l_dgngrd.cc')
-rw-r--r--crawl-ref/source/l_dgngrd.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/crawl-ref/source/l_dgngrd.cc b/crawl-ref/source/l_dgngrd.cc
index ab030df077..23dfc79796 100644
--- a/crawl-ref/source/l_dgngrd.cc
+++ b/crawl-ref/source/l_dgngrd.cc
@@ -29,23 +29,24 @@ static int dgn_feature_name(lua_State *ls)
dungeon_feature_name(static_cast<dungeon_feature_type>(feat)));
}
-static dungeon_feature_type _get_lua_feature(lua_State *ls, int idx)
+static dungeon_feature_type _get_lua_feature(lua_State *ls, int idx,
+ bool optional = false)
{
dungeon_feature_type feat = (dungeon_feature_type)0;
if (lua_isnumber(ls, idx))
feat = (dungeon_feature_type)luaL_checkint(ls, idx);
else if (lua_isstring(ls, idx))
feat = dungeon_feature_by_name(luaL_checkstring(ls, idx));
- else
+ else if (!optional)
luaL_argerror(ls, idx, "Feature must be a string or a feature index.");
return feat;
}
-dungeon_feature_type check_lua_feature(lua_State *ls, int idx)
+dungeon_feature_type check_lua_feature(lua_State *ls, int idx, bool optional)
{
- const dungeon_feature_type f = _get_lua_feature(ls, idx);
- if (!f)
+ const dungeon_feature_type f = _get_lua_feature(ls, idx, optional);
+ if (!optional && !f)
luaL_argerror(ls, idx, "Invalid dungeon feature");
return f;
}