RunScript cleanup, default to 0 return values

This commit is contained in:
Glenn Maynard
2005-02-22 01:21:38 +00:00
parent 1a58675664
commit baf8ef940e
3 changed files with 8 additions and 8 deletions
+6 -6
View File
@@ -272,7 +272,7 @@ bool LuaManager::RunScriptFile( const CString &sFile )
}
CString sError;
if( !RunScript( sScript, sFile, sError ) )
if( !RunScript( sScript, sFile, sError, 0 ) )
{
sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
Dialog::OK( sError, "LUA_ERROR" );
@@ -313,10 +313,10 @@ bool LuaManager::RunScript( const CString &sScript, const CString &sName, CStrin
}
bool LuaManager::RunScript( const CString &sExpression, const CString &sName )
bool LuaManager::RunScript( const CString &sExpression, const CString &sName, int iReturnValues )
{
CString sError;
if( !RunScript( sExpression, sName.size()? sName:"in", sError, 1 ) )
if( !RunScript( sExpression, sName.size()? sName:"in", sError, iReturnValues ) )
{
sError = ssprintf( "Lua runtime error parsing \"%s\": %s", sName.size()? sName.c_str():sExpression.c_str(), sError.c_str() );
Dialog::OK( sError, "LUA_ERROR" );
@@ -328,7 +328,7 @@ bool LuaManager::RunScript( const CString &sExpression, const CString &sName )
bool LuaManager::RunExpressionB( const CString &str )
{
if( !RunScript( "return " + str ) )
if( !RunScript( "return " + str, "", 1 ) )
return false;
/* Don't accept a function as a return value. */
@@ -343,7 +343,7 @@ bool LuaManager::RunExpressionB( const CString &str )
float LuaManager::RunExpressionF( const CString &str )
{
if( !RunScript( "return " + str ) )
if( !RunScript( "return " + str, "", 1 ) )
return 0;
/* Don't accept a function as a return value. */
@@ -363,7 +363,7 @@ int LuaManager::RunExpressionI( const CString &str )
bool LuaManager::RunExpressionS( const CString &str, CString &sOut )
{
if( !RunScript( "return " + str ) )
if( !RunScript( "return " + str, "", 1 ) )
return false;
/* Don't accept a function as a return value. */
+1 -1
View File
@@ -30,7 +30,7 @@ public:
/* Convenience: run a script with one return value, displaying an error on failure.
* The return value is left on the Lua stack. */
bool RunScript( const CString &sExpression, const CString &sName = "" );
bool RunScript( const CString &sExpression, const CString &sName = "", int iReturnValues = 0 );
/* Run an expression in the global environment, returning the given type. */
bool RunExpressionB( const CString &str );
+1 -1
View File
@@ -119,7 +119,7 @@ void LuaExpression::SetFromExpression( const CString &sExpression )
void LuaExpression::Register()
{
if( !LUA->RunScript( m_sExpression ) )
if( !LUA->RunScript( m_sExpression, "expression", 1 ) )
{
this->SetFromNil();
return;