From ad11744e5d49d226fc9c77ed48c3dd8b97921350 Mon Sep 17 00:00:00 2001 From: Darshan Shaligram Date: Fri, 30 Oct 2009 15:46:55 +0530 Subject: 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. --- crawl-ref/source/cluautil.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'crawl-ref/source/cluautil.cc') 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 -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 &s) { - lua_pushstring(ls, s.c_str()); + return clua_gentable(ls, s, clua_pushcxxstring); } -int dlua_stringtable(lua_State *ls, const std::vector &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); } -- cgit v1.2.3-54-g00ecf