when compiling a script from a file, don't dump the entire contents of the
script to the log/dialog
This commit is contained in:
@@ -71,7 +71,13 @@ void ActorCommands::Register()
|
||||
|
||||
|
||||
CString s2 = s.str();
|
||||
LUA->RunScript( s2, "in", 1 );
|
||||
CString sError;
|
||||
if( !LUA->RunScript( s2, "in", sError, 1 ) )
|
||||
{
|
||||
/* We're compiling a generated script, so it should never fail. */
|
||||
FAIL_M( ssprintf("Compiling \"%s\": %s", s2.c_str(), sError.c_str()) );
|
||||
}
|
||||
|
||||
|
||||
/* The function is now on the stack. */
|
||||
this->SetFromStack();
|
||||
|
||||
@@ -261,10 +261,18 @@ bool LuaManager::RunScriptFile( const CString &sFile )
|
||||
return false;
|
||||
}
|
||||
|
||||
return RunScript( sScript, sFile );
|
||||
CString sError;
|
||||
if( !RunScript( sScript, sFile, sError ) )
|
||||
{
|
||||
sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
|
||||
Dialog::OK( sError, "LUA_ERROR" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LuaManager::RunScript( const CString &sScript, const CString &sName, int iReturnValues )
|
||||
bool LuaManager::RunScript( const CString &sScript, const CString &sName, CString &sError, int iReturnValues )
|
||||
{
|
||||
// load string
|
||||
{
|
||||
@@ -274,10 +282,7 @@ bool LuaManager::RunScript( const CString &sScript, const CString &sName, int iR
|
||||
|
||||
if( ret )
|
||||
{
|
||||
CString err;
|
||||
LuaManager::PopStack( err );
|
||||
CString sError = ssprintf( "Lua runtime error parsing \"%s\": %s", sScript.c_str(), err.c_str() );
|
||||
Dialog::OK( sError, "LUA_ERROR" );
|
||||
LuaManager::PopStack( sError );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -303,8 +308,13 @@ bool LuaManager::RunScript( const CString &sScript, const CString &sName, int iR
|
||||
|
||||
bool LuaManager::RunExpression( const CString &sExpression )
|
||||
{
|
||||
if( !RunScript( "return " + sExpression, "in", 1 ) )
|
||||
CString sError;
|
||||
if( !RunScript( "return " + sExpression, "in", sError, 1 ) )
|
||||
{
|
||||
sError = ssprintf( "Lua runtime error parsing \"%s\": %s", sExpression.c_str(), sError.c_str() );
|
||||
Dialog::OK( sError, "LUA_ERROR" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
void ResetState();
|
||||
|
||||
/* Run a complete script in the global environment, which returns no value. */
|
||||
bool RunScript( const CString &sScript, const CString &sName, int iReturnValues = 0 );
|
||||
bool RunScript( const CString &sScript, const CString &sName, CString &sError, int iReturnValues = 0 );
|
||||
|
||||
/* Run an expression in the global environment, returning the given type. */
|
||||
bool RunExpressionB( const CString &str );
|
||||
|
||||
Reference in New Issue
Block a user