EgtGeneral 1.6p3 :
- aggiunto metodo LuaMgr::ExistsFunction.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user