LuaHelpers::PrepareExpression
This commit is contained in:
@@ -52,12 +52,12 @@ void ActorFrame::LoadFromNode( const CString& sDir, const XNode* pNode )
|
|||||||
CString s;
|
CString s;
|
||||||
if( pNode->GetAttrValue( "VanishX", s ) )
|
if( pNode->GetAttrValue( "VanishX", s ) )
|
||||||
{
|
{
|
||||||
LUA->PrepareExpression( s );
|
LuaHelpers::PrepareExpression( s );
|
||||||
m_fVanishX = LuaHelpers::RunExpressionF( s );
|
m_fVanishX = LuaHelpers::RunExpressionF( s );
|
||||||
}
|
}
|
||||||
if( pNode->GetAttrValue( "VanishY", s ) )
|
if( pNode->GetAttrValue( "VanishY", s ) )
|
||||||
{
|
{
|
||||||
LUA->PrepareExpression( s );
|
LuaHelpers::PrepareExpression( s );
|
||||||
m_fVanishY = LuaHelpers::RunExpressionF( s );
|
m_fVanishY = LuaHelpers::RunExpressionF( s );
|
||||||
}
|
}
|
||||||
m_bOverrideLighting = pNode->GetAttrValue( "Lighting", m_bLighting );
|
m_bOverrideLighting = pNode->GetAttrValue( "Lighting", m_bLighting );
|
||||||
|
|||||||
@@ -40,19 +40,19 @@ Command::Arg::operator CString ()
|
|||||||
|
|
||||||
Command::Arg::operator float ()
|
Command::Arg::operator float ()
|
||||||
{
|
{
|
||||||
LUA->PrepareExpression( s ); // strip invalid chars
|
LuaHelpers::PrepareExpression( s ); // strip invalid chars
|
||||||
return LuaHelpers::RunExpressionF( s );
|
return LuaHelpers::RunExpressionF( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Arg::operator int ()
|
Command::Arg::operator int ()
|
||||||
{
|
{
|
||||||
LUA->PrepareExpression( s ); // strip invalid chars
|
LuaHelpers::PrepareExpression( s ); // strip invalid chars
|
||||||
return (int) LuaHelpers::RunExpressionF( s );
|
return (int) LuaHelpers::RunExpressionF( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Arg::operator bool ()
|
Command::Arg::operator bool ()
|
||||||
{
|
{
|
||||||
LUA->PrepareExpression( s ); // strip invalid chars
|
LuaHelpers::PrepareExpression( s ); // strip invalid chars
|
||||||
return LuaHelpers::RunExpressionF( s ) != 0.0f;
|
return LuaHelpers::RunExpressionF( s ) != 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void LuaManager::ResetState()
|
|||||||
m_pLock->Unlock();
|
m_pLock->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaManager::PrepareExpression( CString &sInOut )
|
void LuaHelpers::PrepareExpression( CString &sInOut )
|
||||||
{
|
{
|
||||||
// HACK: Many metrics have "//" comments that Lua fails to parse.
|
// HACK: Many metrics have "//" comments that Lua fails to parse.
|
||||||
// Replace them with Lua-style comments.
|
// Replace them with Lua-style comments.
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ public:
|
|||||||
Lua *Get();
|
Lua *Get();
|
||||||
void Release( Lua *&p );
|
void Release( Lua *&p );
|
||||||
|
|
||||||
void PrepareExpression( CString &sInOut ); // strip "//" comments and "+"
|
|
||||||
|
|
||||||
/* Reset the environment, freeing any globals left over by previously executed scripts. */
|
/* Reset the environment, freeing any globals left over by previously executed scripts. */
|
||||||
void ResetState();
|
void ResetState();
|
||||||
|
|
||||||
@@ -86,6 +84,9 @@ namespace LuaHelpers
|
|||||||
|
|
||||||
bool RunScriptFile( const CString &sFile );
|
bool RunScriptFile( const CString &sFile );
|
||||||
|
|
||||||
|
/* Strip "//" comments and "+". */
|
||||||
|
void PrepareExpression( CString &sInOut );
|
||||||
|
|
||||||
/* Create a Lua array (a table with indices starting at 1) of the given vector,
|
/* Create a Lua array (a table with indices starting at 1) of the given vector,
|
||||||
* and push it on the stack. */
|
* and push it on the stack. */
|
||||||
void CreateTableFromArrayB( Lua *L, const vector<bool> &aIn );
|
void CreateTableFromArrayB( Lua *L, const vector<bool> &aIn );
|
||||||
|
|||||||
@@ -717,7 +717,7 @@ float ThemeManager::GetMetricF( const CString &sClassName, const CString &sValue
|
|||||||
{
|
{
|
||||||
CString sValue = GetMetric( sClassName, sValueName ); // Use non-raw so that Lua expressions are allowed
|
CString sValue = GetMetric( sClassName, sValueName ); // Use non-raw so that Lua expressions are allowed
|
||||||
|
|
||||||
LUA->PrepareExpression( sValue );
|
LuaHelpers::PrepareExpression( sValue );
|
||||||
|
|
||||||
return LuaHelpers::RunExpressionF( sValue );
|
return LuaHelpers::RunExpressionF( sValue );
|
||||||
}
|
}
|
||||||
@@ -737,7 +737,7 @@ bool ThemeManager::GetMetricB( const CString &sClassName, const CString &sValueN
|
|||||||
if( sValue.Left(1) == "1" )
|
if( sValue.Left(1) == "1" )
|
||||||
return true; /* optimization */
|
return true; /* optimization */
|
||||||
|
|
||||||
LUA->PrepareExpression( sValue );
|
LuaHelpers::PrepareExpression( sValue );
|
||||||
|
|
||||||
return LuaHelpers::RunExpressionB( sValue );
|
return LuaHelpers::RunExpressionB( sValue );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user