diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-25 23:36:07 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-25 23:36:07 +0000 |
commit | 83b1c7b2cc01d46d8f904b102681e85c044710a0 (patch) | |
tree | 9d76a04ce3d820458e18b87c7283f4f68b4f2fa4 /crawl-ref/source/clua.cc | |
parent | 527fdaf6347eeec4683c418593c1977ab77c5007 (diff) | |
download | crawl-ref-83b1c7b2cc01d46d8f904b102681e85c044710a0.tar.gz crawl-ref-83b1c7b2cc01d46d8f904b102681e85c044710a0.zip |
Place external loot chamber for ziggurat levels with jellies.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7625 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/clua.cc')
-rw-r--r-- | crawl-ref/source/clua.cc | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 2204d17cf1..3be3f4398e 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -658,6 +658,7 @@ void CLua::init_lua() CLua &CLua::get_vm(lua_State *ls) { + lua_stack_cleaner clean(ls); _getregistry(ls, "__clua"); CLua *vm = util_get_userdata<CLua>(ls, -1); if (!vm) @@ -2516,6 +2517,27 @@ MDEF(hd) PLUARET(number, mons->hit_dice); } +static const char *_monuse_names[] = +{ + "nothing", "eats_items", "open_doors", "starting_equipment", + "weapons_armour", "magic_items" +}; + +static const char *_monuse_to_str(mon_itemuse_type ityp) +{ + ASSERT(ARRAYSZ(_monuse_names) == NUM_MONUSE); + return _monuse_names[ityp]; +} + +MDEF(muse) +{ + if (const monsterentry *me = mons->find_monsterentry()) + { + PLUARET(string, _monuse_to_str(me->gmon_use)); + } + return (0); +} + static int l_mons_do_dismiss(lua_State *ls) { // dismiss is only callable from dlua, not from managed VMs (i.e. @@ -2551,6 +2573,7 @@ static MonsAccessor mons_attrs[] = { "x" , l_mons_x }, { "y" , l_mons_y }, { "hd" , l_mons_hd }, + { "muse", l_mons_muse }, { "dismiss", l_mons_dismiss }, { "experience", l_mons_experience }, }; @@ -2627,6 +2650,12 @@ void clua_push_map(lua_State *ls, map_def *map) *mapref = map; } +void clua_push_coord(lua_State *ls, const coord_def &c) +{ + lua_pushnumber(ls, c.x); + lua_pushnumber(ls, c.y); +} + void clua_push_dgn_event(lua_State *ls, const dgn_event *devent) { const dgn_event **de = @@ -3051,7 +3080,7 @@ lua_shutdown_listener::~lua_shutdown_listener() } lua_datum::lua_datum(CLua &_lua, int stackpos, bool pop) - : need_cleanup(true), lua(_lua) + : lua(_lua), need_cleanup(true) { // Store the datum in the registry indexed by "this". lua_pushvalue(lua, stackpos); @@ -3067,13 +3096,28 @@ lua_datum::lua_datum(CLua &_lua, int stackpos, bool pop) } lua_datum::lua_datum(const lua_datum &o) - : need_cleanup(true), lua(o.lua) + : lua(o.lua), need_cleanup(true) +{ + set_from(o); +} + +void lua_datum::set_from(const lua_datum &o) { lua_pushlightuserdata(lua, this); o.push(); lua_settable(lua, LUA_REGISTRYINDEX); - lua.add_shutdown_listener(this); + need_cleanup = true; +} + +const lua_datum &lua_datum::operator = (const lua_datum &o) +{ + if (this != &o) + { + cleanup(); + set_from(o); + } + return (*this); } void lua_datum::push() const |