summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/l_dgn.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-30 15:46:55 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-31 22:16:46 +0530
commitad11744e5d49d226fc9c77ed48c3dd8b97921350 (patch)
treec4334fd1e6b4b052ac93593f9021f12c9f10baac /crawl-ref/source/l_dgn.cc
parent23f8631266eac1a7b4b4727b26a5fc088a6f0184 (diff)
downloadcrawl-ref-ad11744e5d49d226fc9c77ed48c3dd8b97921350.tar.gz
crawl-ref-ad11744e5d49d226fc9c77ed48c3dd8b97921350.zip
lmark.synchronized_markers(): apply one marker's effects to multiple points simultaneously.
synchronized_markers() takes a marker, and a list of method names to override, and returns a set of markers that fire simultaneously, to allow, say, fog machines that fire at random intervals, but always fire in unison. lm_mslav.lua has details. volcano.des has an example volcano entry vault that uses this. Allow fetching a list of Lua markers/marker positions by property value. Renamed dgn.find_marker_prop -> dgn.find_marker_position_by_prop. s/helper/listener/ for fog machine listeners.
Diffstat (limited to 'crawl-ref/source/l_dgn.cc')
-rw-r--r--crawl-ref/source/l_dgn.cc40
1 files changed, 36 insertions, 4 deletions
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc
index 86d142192e..180ffc87ab 100644
--- a/crawl-ref/source/l_dgn.cc
+++ b/crawl-ref/source/l_dgn.cc
@@ -356,7 +356,7 @@ static int dgn_map(lua_State *ls)
{
MAP(ls, 1, map);
if (lua_gettop(ls) == 1)
- return dlua_stringtable(ls, map->map.get_lines());
+ return clua_stringtable(ls, map->map.get_lines());
if (lua_isnil(ls, 2))
{
@@ -1407,12 +1407,12 @@ LUAFN(_dgn_in_vault)
return (1);
}
-LUAFN(_dgn_find_marker_prop)
+LUAFN(_dgn_find_marker_position_by_prop)
{
const char *prop = luaL_checkstring(ls, 1);
const std::string value(
lua_gettop(ls) >= 2 ? luaL_checkstring(ls, 2) : "");
- const coord_def place = find_marker_prop(prop, value);
+ const coord_def place = find_marker_position_by_prop(prop, value);
if (map_bounds(place))
clua_push_coord(ls, place);
else
@@ -1423,6 +1423,36 @@ LUAFN(_dgn_find_marker_prop)
return (2);
}
+LUAFN(_dgn_find_marker_positions_by_prop)
+{
+ const char *prop = luaL_checkstring(ls, 1);
+ const std::string value(
+ lua_gettop(ls) >= 2 ? luaL_checkstring(ls, 2) : "");
+ const unsigned limit(lua_gettop(ls) >= 3 ? luaL_checkint(ls, 3) : 0);
+ const std::vector<coord_def> places =
+ find_marker_positions_by_prop(prop, value, limit);
+ clua_gentable(ls, places, clua_pushpoint);
+ return (1);
+}
+
+static int _push_mapmarker(lua_State *ls, map_marker *marker)
+{
+ dlua_push_userdata(ls, marker, MAPMARK_METATABLE);
+ return (1);
+}
+
+LUAFN(_dgn_find_markers_by_prop)
+{
+ const char *prop = luaL_checkstring(ls, 1);
+ const std::string value(
+ lua_gettop(ls) >= 2 ? luaL_checkstring(ls, 2) : "");
+ const unsigned limit(lua_gettop(ls) >= 3 ? luaL_checkint(ls, 3) : 0);
+ const std::vector<map_marker*> places =
+ find_markers_by_prop(prop, value, limit);
+ clua_gentable(ls, places, _push_mapmarker);
+ return (1);
+}
+
extern spec_room lua_special_room_spec;
extern int lua_special_room_level;
@@ -1588,7 +1618,9 @@ const struct luaL_reg dgn_dlib[] =
{ "resolve_map", _dgn_resolve_map },
{ "in_vault", _dgn_in_vault },
-{ "find_marker_prop", _dgn_find_marker_prop },
+{ "find_marker_position_by_prop", _dgn_find_marker_position_by_prop },
+{ "find_marker_positions_by_prop", _dgn_find_marker_positions_by_prop },
+{ "find_markers_by_prop", _dgn_find_markers_by_prop },
{ "get_special_room_info", dgn_get_special_room_info },