diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-03-17 21:56:00 +0100 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-03-17 23:40:12 +0100 |
commit | a6c3eed2b9a91e9768ec6ce137879cac13703dea (patch) | |
tree | b85bd802a6169dfd2e99f99d3150004d7e90e6a0 /src/scripting/lua.cpp | |
parent | f98ba725442348584810c089111501a07ac59905 (diff) | |
download | manaserv-a6c3eed2b9a91e9768ec6ce137879cac13703dea.tar.gz manaserv-a6c3eed2b9a91e9768ec6ce137879cac13703dea.tar.bz2 manaserv-a6c3eed2b9a91e9768ec6ce137879cac13703dea.tar.xz manaserv-a6c3eed2b9a91e9768ec6ce137879cac13703dea.zip |
Added map update function, moved schedules there to keep map context
Reviewed-by: bjorn.
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index c5ab16ff..136350da 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -168,6 +168,13 @@ static int on_worldvar_changed(lua_State *s) return 0; } +static int on_mapupdate(lua_State *s) +{ + luaL_checktype(s, 1, LUA_TFUNCTION); + MapComposite::setUpdateCallback(getScript(s)); + return 0; +} + static int get_item_class(lua_State *s) { LuaItemClass::push(s, checkItemClass(s, 1)); @@ -1921,8 +1928,13 @@ static int test_tableget(lua_State *s) */ static int get_map_id(lua_State *s) { - MapComposite *m = checkCurrentMap(s); - lua_pushinteger(s, m->getID()); + Script *script = getScript(s); + + if (MapComposite *mapComposite = script->getMap()) + lua_pushinteger(s, mapComposite->getID()); + else + lua_pushnil(s); + return 1; } @@ -2232,6 +2244,7 @@ LuaScript::LuaScript(): { "on_get_special_recharge_cost", &on_get_special_recharge_cost }, { "on_mapvar_changed", &on_mapvar_changed }, { "on_worldvar_changed", &on_worldvar_changed }, + { "on_mapupdate", &on_mapupdate }, { "get_item_class", &get_item_class }, { "get_monster_class", &get_monster_class }, { "get_status_effect", &get_status_effect }, |