diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index 56ef7e21de..e424ac3fe3 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -287,7 +287,7 @@ bool LuaHelpers::RunScript( Lua *L, const CString &sScript, const CString &sName } -bool LuaManager::RunScript( const CString &sExpression, const CString &sName, int iReturnValues ) +bool LuaHelpers::RunScript( Lua *L, const CString &sExpression, const CString &sName, int iReturnValues ) { CString sError; if( !LuaHelpers::RunScript( L, sExpression, sName.size()? sName:CString("in"), sError, iReturnValues ) ) @@ -302,7 +302,7 @@ bool LuaManager::RunScript( const CString &sExpression, const CString &sName, in bool LuaManager::RunExpressionB( const CString &str ) { - if( !RunScript( "return " + str, "", 1 ) ) + if( !LuaHelpers::RunScript(L, "return " + str, "", 1) ) return false; /* Don't accept a function as a return value. */ @@ -317,7 +317,7 @@ bool LuaManager::RunExpressionB( const CString &str ) float LuaManager::RunExpressionF( const CString &str ) { - if( !RunScript( "return " + str, "", 1 ) ) + if( !LuaHelpers::RunScript(L, "return " + str, "", 1) ) return 0; /* Don't accept a function as a return value. */ @@ -337,7 +337,7 @@ int LuaManager::RunExpressionI( const CString &str ) bool LuaManager::RunExpressionS( const CString &str, CString &sOut ) { - if( !RunScript( "return " + str, "", 1 ) ) + if( !LuaHelpers::RunScript(L, "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 660e072be7..3594503e73 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -59,10 +59,6 @@ public: /* Reset the environment, freeing any globals left over by previously executed scripts. */ void ResetState(); - /* 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 = "", int iReturnValues = 0 ); - /* Run an expression in the global environment, returning the given type. */ bool RunExpressionB( const CString &str ); float RunExpressionF( const CString &str ); @@ -95,6 +91,10 @@ namespace LuaHelpers * Returns false on error, with sError set. */ bool RunScript( Lua *L, const CString &sScript, const CString &sName, CString &sError, int iReturnValues = 0 ); + /* Convenience: run a script with one return value, displaying an error on failure. + * The return value is left on the Lua stack. */ + bool RunScript( Lua *L, const CString &sExpression, const CString &sName = "", int iReturnValues = 0 ); + bool RunScriptFile( const CString &sFile ); /* Create a Lua array (a table with indices starting at 1) of the given vector, diff --git a/stepmania/src/LuaReference.cpp b/stepmania/src/LuaReference.cpp index a2c66ca13e..1d7c28dc28 100644 --- a/stepmania/src/LuaReference.cpp +++ b/stepmania/src/LuaReference.cpp @@ -145,7 +145,7 @@ void LuaExpression::Register() { Lua *L = LUA->Get(); - if( !LUA->RunScript( m_sExpression, "expression", 1 ) ) + if( !LuaHelpers::RunScript(L, m_sExpression, "expression", 1) ) { this->SetFromNil(); LUA->Release( L );