summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/cluautil.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/cluautil.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/cluautil.cc')
-rw-r--r--crawl-ref/source/cluautil.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/crawl-ref/source/cluautil.cc b/crawl-ref/source/cluautil.cc
index e55b836f3e..a9cb1cec7b 100644
--- a/crawl-ref/source/cluautil.cc
+++ b/crawl-ref/source/cluautil.cc
@@ -99,25 +99,24 @@ void clua_register_metatable(lua_State *ls, const char *tn,
}
}
-
-template <typename list, typename lpush>
-static int dlua_gentable(lua_State *ls, const list &strings, lpush push)
+int clua_pushcxxstring(lua_State *ls, const std::string &s)
{
- lua_newtable(ls);
- for (int i = 0, size = strings.size(); i < size; ++i)
- {
- push(ls, strings[i]);
- lua_rawseti(ls, -2, i + 1);
- }
+ lua_pushstring(ls, s.c_str());
return (1);
}
-inline static void dlua_pushcxxstring(lua_State *ls, const std::string &s)
+int clua_stringtable(lua_State *ls, const std::vector<std::string> &s)
{
- lua_pushstring(ls, s.c_str());
+ return clua_gentable(ls, s, clua_pushcxxstring);
}
-int dlua_stringtable(lua_State *ls, const std::vector<std::string> &s)
+int clua_pushpoint(lua_State *ls, const coord_def &pos)
{
- return dlua_gentable(ls, s, dlua_pushcxxstring);
+ lua_pushnumber(ls, pos.x);
+ lua_pushnumber(ls, pos.y);
+ CLua &vm(CLua::get_vm(ls));
+ if (!vm.callfn("dgn.point", 2, 1))
+ luaL_error(ls, "dgn.point(%d,%d) failed: %s",
+ pos.x, pos.y, vm.error.c_str());
+ return (1);
}