From baf8ef940ebcb8e77694c56764daa15e9de357a3 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 22 Feb 2005 01:21:38 +0000 Subject: [PATCH] RunScript cleanup, default to 0 return values --- stepmania/src/LuaManager.cpp | 12 ++++++------ stepmania/src/LuaManager.h | 2 +- stepmania/src/LuaReference.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index 4c272738be..926529363c 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -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. */ diff --git a/stepmania/src/LuaManager.h b/stepmania/src/LuaManager.h index 7bdf77728b..dd71937cd3 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -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 ); diff --git a/stepmania/src/LuaReference.cpp b/stepmania/src/LuaReference.cpp index 898c718dba..3771cbed9c 100644 --- a/stepmania/src/LuaReference.cpp +++ b/stepmania/src/LuaReference.cpp @@ -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;