Include :
- migliorie e correzioni a funzioni inline per accedere a variabili globali strutturate lua.
This commit is contained in:
+19
-5
@@ -528,13 +528,21 @@ LuaGetGlobVar( lua_State* L, const std::string& sVar, T& Val)
|
||||
int nTokenCnt = int( vsTokens.size()) ;
|
||||
if ( nTokenCnt < 2)
|
||||
return false ;
|
||||
lua_getglobal( L, vsTokens[0].c_str()) ;
|
||||
if ( lua_getglobal( L, vsTokens[0].c_str()) != LUA_TTABLE) {
|
||||
lua_pop( L, 1) ;
|
||||
return false ;
|
||||
}
|
||||
for ( int nInd = 1 ; nInd <= nTokenCnt - 2 ; ++ nInd) {
|
||||
bool bOk ;
|
||||
int nField ;
|
||||
if ( FromString( vsTokens[nInd], nField))
|
||||
lua_rawgeti( L, -1, nField) ;
|
||||
bOk = ( lua_rawgeti( L, -1, nField) == LUA_TTABLE) ;
|
||||
else
|
||||
lua_getfield( L, -1, vsTokens[nInd].c_str()) ;
|
||||
bOk = ( lua_getfield( L, -1, vsTokens[nInd].c_str()) == LUA_TTABLE) ;
|
||||
if ( ! bOk) {
|
||||
lua_pop( L, nInd + 1) ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
bool bOk = LuaGetTabFieldParam( L, -1, vsTokens[nTokenCnt-1].c_str(), Val) ;
|
||||
lua_pop( L, nTokenCnt - 1) ;
|
||||
@@ -563,7 +571,10 @@ LuaSetGlobVar( lua_State* L, const std::string& sVar, const T& Val)
|
||||
int nTokenCnt = int( vsTokens.size()) ;
|
||||
if ( nTokenCnt < 2)
|
||||
return false ;
|
||||
lua_getglobal( L, vsTokens[0].c_str()) ;
|
||||
if ( lua_getglobal( L, vsTokens[0].c_str()) != LUA_TTABLE) {
|
||||
lua_pop( L, 1) ;
|
||||
return false ;
|
||||
}
|
||||
for ( int nInd = 1 ; nInd <= nTokenCnt - 2 ; ++ nInd) {
|
||||
int nField ;
|
||||
bool bNumber = FromString( vsTokens[nInd], nField) ;
|
||||
@@ -603,7 +614,10 @@ LuaResetGlobVar( lua_State* L, const std::string& sVar)
|
||||
int nTokenCnt = int( vsTokens.size()) ;
|
||||
if ( nTokenCnt < 2)
|
||||
return false ;
|
||||
lua_getglobal( L, vsTokens[0].c_str()) ;
|
||||
if ( lua_getglobal( L, vsTokens[0].c_str()) != LUA_TTABLE) {
|
||||
lua_pop( L, 1) ;
|
||||
return false ;
|
||||
}
|
||||
for ( int nInd = 1 ; nInd <= nTokenCnt - 2 ; ++ nInd) {
|
||||
int nField ;
|
||||
bool bNumber = FromString( vsTokens[nInd], nField) ;
|
||||
|
||||
Reference in New Issue
Block a user