LuaHelpers::RunExpression

This commit is contained in:
Glenn Maynard
2006-09-22 18:53:39 +00:00
parent a7a6d643a4
commit 494c3cd485
2 changed files with 15 additions and 0 deletions
+11
View File
@@ -539,6 +539,17 @@ bool LuaHelpers::RunScript( Lua *L, const RString &sExpression, const RString &s
return true;
}
bool LuaHelpers::RunExpression( Lua *L, const RString &sExpression )
{
RString sFullExpression = "return " + sExpression;
bool bSuccess = LuaHelpers::RunScript( L, sFullExpression, "", 1 );
if( !bSuccess )
lua_pushnil( L );
return bSuccess;
}
bool LuaHelpers::RunExpressionB( const RString &str )
{
Lua *L = LUA->Get();
+4
View File
@@ -56,6 +56,10 @@ namespace LuaHelpers
* The return value is left on the Lua stack. */
bool RunScript( Lua *L, const RString &sExpression, const RString &sName = "", int iReturnValues = 0 );
/* Run the given expression, returning a single value, and leave the return value on the
* stack. On error, push nil. */
bool RunExpression( Lua *L, const RString &sExpression );
bool RunScriptFile( const RString &sFile );
/* Strip "//" comments and "+". */