From 5a7b227245e5c4ba1901925fb71a018d2d650efb Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Sun, 16 Dec 2012 18:40:12 +1000 Subject: [PATCH] - added getAreaTableSwap() --- src/TLuaInterpreter.cpp | 18 ++++++++++++++++++ src/TLuaInterpreter.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/TLuaInterpreter.cpp b/src/TLuaInterpreter.cpp index dd1fa4d..6ad5e43 100644 --- a/src/TLuaInterpreter.cpp +++ b/src/TLuaInterpreter.cpp @@ -3877,6 +3877,23 @@ int TLuaInterpreter::getAreaTable( lua_State *L ) return 1; } +int TLuaInterpreter::getAreaTableSwap( lua_State *L ) +{ + Host * pHost = TLuaInterpreter::luaInterpreterMap[L]; + QMapIterator it( pHost->mpMap->areaNamesMap ); + lua_newtable(L); + while( it.hasNext() ) + { + it.next(); + int roomID = it.key(); + QString name = it.value(); + lua_pushnumber( L, roomID ); + lua_pushstring( L, name.toLatin1().data() ); + lua_settable(L, -3); + } + return 1; +} + int TLuaInterpreter::getAreaRooms( lua_State *L ) { int area; @@ -9533,6 +9550,7 @@ void TLuaInterpreter::initLuaGlobals() lua_register( pGlobalLua, "searchRoom", TLuaInterpreter::searchRoom ); lua_register( pGlobalLua, "clearCmdLine", TLuaInterpreter::clearCmdLine ); lua_register( pGlobalLua, "getAreaTable", TLuaInterpreter::getAreaTable ); + lua_register( pGlobalLua, "getAreaTableSwap", TLuaInterpreter::getAreaTableSwap ); lua_register( pGlobalLua, "getAreaRooms", TLuaInterpreter::getAreaRooms ); lua_register( pGlobalLua, "getPath", TLuaInterpreter::getPath ); lua_register( pGlobalLua, "centerview", TLuaInterpreter::centerview ); diff --git a/src/TLuaInterpreter.h b/src/TLuaInterpreter.h index 9b869e5..a943514 100644 --- a/src/TLuaInterpreter.h +++ b/src/TLuaInterpreter.h @@ -179,6 +179,7 @@ public: static int tempExactMatchTrigger( lua_State * ); static int centerview( lua_State *L ); static int getAreaTable( lua_State *L ); + static int getAreaTableSwap( lua_State *L ); static int getPath( lua_State * ); static int getAreaRooms( lua_State * ); static int clearCmdLine( lua_State * ); -- 1.7.9.5