EgtGeneral 1.6p3 :

- aggiunto metodo LuaMgr::ExistsFunction.
This commit is contained in:
Dario Sassi
2016-04-19 15:46:22 +00:00
parent 9173123610
commit 245bf254f2
2 changed files with 24 additions and 0 deletions
+24
View File
@@ -241,6 +241,30 @@ LuaMgr::ExecFile( const string& sFile)
}
}
//----------------------------------------------------------------------------
bool
LuaMgr::ExistsFunction( const string& sFunName)
{
// recupero la funzione
if ( sFunName.find( '.') == std::string::npos) {
// è direttamente il nome
lua_getglobal( m_pL, sFunName.c_str()) ;
}
else {
// è in una tavola
std::string sTab, sField ;
SplitFirst( sFunName, ".", sTab, sField) ;
lua_getglobal( m_pL, sTab.c_str()) ;
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) ;
lua_pop( m_pL, 1) ;
}
bool bOk = ( lua_isfunction( m_pL, -1) != 0) ;
lua_pop( m_pL, 1) ;
return bOk ;
}
//----------------------------------------------------------------------------
void
LuaMgr::LogError( const string& sErr)