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:
Glenn Maynard
2005-02-15 07:17:49 +00:00
parent 6d7f4cf150
commit 8584cbc0d7
3 changed files with 25 additions and 9 deletions
+7 -1
View File
@@ -71,7 +71,13 @@ void ActorCommands::Register()
CString s2 = s.str(); 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. */ /* The function is now on the stack. */
this->SetFromStack(); this->SetFromStack();
+17 -7
View File
@@ -261,10 +261,18 @@ bool LuaManager::RunScriptFile( const CString &sFile )
return false; 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 // load string
{ {
@@ -274,10 +282,7 @@ bool LuaManager::RunScript( const CString &sScript, const CString &sName, int iR
if( ret ) if( ret )
{ {
CString err; LuaManager::PopStack( sError );
LuaManager::PopStack( err );
CString sError = ssprintf( "Lua runtime error parsing \"%s\": %s", sScript.c_str(), err.c_str() );
Dialog::OK( sError, "LUA_ERROR" );
return false; return false;
} }
@@ -303,8 +308,13 @@ bool LuaManager::RunScript( const CString &sScript, const CString &sName, int iR
bool LuaManager::RunExpression( const CString &sExpression ) 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 false;
}
return true; return true;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ public:
void ResetState(); void ResetState();
/* Run a complete script in the global environment, which returns no value. */ /* 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. */ /* Run an expression in the global environment, returning the given type. */
bool RunExpressionB( const CString &str ); bool RunExpressionB( const CString &str );