diff --git a/stepmania/src/LuaReference.cpp b/stepmania/src/LuaReference.cpp index 3277d8d6d0..3d2073d0ac 100644 --- a/stepmania/src/LuaReference.cpp +++ b/stepmania/src/LuaReference.cpp @@ -138,23 +138,20 @@ void LuaReference::Unregister() m_iReference = LUA_NOREF; } -void LuaReference::SetFromExpression( const RString &sExpression ) +bool LuaReference::SetFromExpression( const RString &sExpression ) { RString sFullExpression = "return " + sExpression; SetName( sFullExpression ); Lua *L = LUA->Get(); - if( !LuaHelpers::RunScript(L, sFullExpression, "expression", 1) ) - { + bool bSuccess = LuaHelpers::RunScript(L, sFullExpression, "expression", 1); + if( !bSuccess ) this->SetFromNil(); - LUA->Release( L ); - return; - } - - /* Store the result. */ - this->SetFromStack( L ); + else + this->SetFromStack( L ); LUA->Release( L ); + return bSuccess; } RString LuaReference::Serialize() const diff --git a/stepmania/src/LuaReference.h b/stepmania/src/LuaReference.h index d28ce550a1..735e72e896 100644 --- a/stepmania/src/LuaReference.h +++ b/stepmania/src/LuaReference.h @@ -22,8 +22,9 @@ public: void SetFromNil(); /* Evaluate an expression that returns an object; store the object in a reference. - * For example, evaluating "{ 1, 2, 3 }" will result in a reference to a table. */ - void SetFromExpression( const RString &sExpression ); + * For example, evaluating "{ 1, 2, 3 }" will result in a reference to a table. + * On success, return true. On error, set to nil and return false. */ + bool SetFromExpression( const RString &sExpression ); /* Deep-copy tables, detaching this reference from any others. */ void DeepCopy();