LuaHelpers::RunScript

This commit is contained in:
Glenn Maynard
2005-06-16 06:17:32 +00:00
parent b93399da8c
commit 914acb4b7b
3 changed files with 9 additions and 9 deletions
+4 -4
View File
@@ -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. */
+4 -4
View File
@@ -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,
+1 -1
View File
@@ -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 );