Include :

- migliorati controlli in accesso a campi di tavole Lua.
This commit is contained in:
Dario Sassi
2017-01-16 19:19:04 +00:00
parent 2baeddf1ba
commit 395c27bc81
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -438,6 +438,8 @@ LuaGetGlobVar( lua_State* L, const std::string& sVar, T& Val)
std::string sTab, sField ;
SplitFirst( sVar, ".", sTab, sField) ;
lua_getglobal( L, sTab.c_str()) ;
if ( ! lua_istable( L, -1))
return false ;
bool bOk = LuaGetTabFieldParam( L, -1, sField.c_str(), Val) ;
lua_pop( L, 1) ;
return bOk ;
+2
View File
@@ -101,6 +101,8 @@ LuaMgr::CallFunction( const std::string& sFunName, int nRets, const Args&... par
std::string sTab, sField ;
SplitFirst( sFunName, ".", sTab, sField) ;
lua_getglobal( m_pL, sTab.c_str()) ;
if ( ! lua_istable( m_pL, -1))
return false ;
lua_getfield( m_pL, -1, sField.c_str()) ;
// porto la funzione uno slot sotto e diminuisco lo stack di uno (per essere come caso sopra)
lua_copy( m_pL, -1, -2) ;