LuaHelpers::RunExpressionF

This commit is contained in:
Glenn Maynard
2005-06-16 06:30:33 +00:00
parent 6a8940d5a4
commit cb3f10aabb
6 changed files with 15 additions and 10 deletions
+2 -2
View File
@@ -53,12 +53,12 @@ void ActorFrame::LoadFromNode( const CString& sDir, const XNode* pNode )
if( pNode->GetAttrValue( "VanishX", s ) )
{
LUA->PrepareExpression( s );
m_fVanishX = LUA->RunExpressionF( s );
m_fVanishX = LuaHelpers::RunExpressionF( s );
}
if( pNode->GetAttrValue( "VanishY", s ) )
{
LUA->PrepareExpression( s );
m_fVanishY = LUA->RunExpressionF( s );
m_fVanishY = LuaHelpers::RunExpressionF( s );
}
m_bOverrideLighting = pNode->GetAttrValue( "Lighting", m_bLighting );
}
+3 -3
View File
@@ -41,19 +41,19 @@ Command::Arg::operator CString ()
Command::Arg::operator float ()
{
LUA->PrepareExpression( s ); // strip invalid chars
return LUA->RunExpressionF( s );
return LuaHelpers::RunExpressionF( s );
}
Command::Arg::operator int ()
{
LUA->PrepareExpression( s ); // strip invalid chars
return (int)LUA->RunExpressionF( s );
return (int) LuaHelpers::RunExpressionF( s );
}
Command::Arg::operator bool ()
{
LUA->PrepareExpression( s ); // strip invalid chars
return LUA->RunExpressionF( s ) != 0.0f;
return LuaHelpers::RunExpressionF( s ) != 0.0f;
}
void Command::Load( const CString &sCommand )
+7 -2
View File
@@ -321,10 +321,14 @@ bool LuaHelpers::RunExpressionB( const CString &str )
return result;
}
float LuaManager::RunExpressionF( const CString &str )
float LuaHelpers::RunExpressionF( const CString &str )
{
Lua *L = LUA->Get();
if( !LuaHelpers::RunScript(L, "return " + str, "", 1) )
{
LUA->Release(L);
return 0;
}
/* Don't accept a function as a return value. */
if( lua_isfunction( L, -1 ) )
@@ -333,12 +337,13 @@ float LuaManager::RunExpressionF( const CString &str )
float result = (float) lua_tonumber( L, -1 );
lua_pop( L, 1 );
LUA->Release(L);
return result;
}
int LuaManager::RunExpressionI( const CString &str )
{
return (int)RunExpressionF(str);
return (int) LuaHelpers::RunExpressionF(str);
}
bool LuaManager::RunExpressionS( const CString &str, CString &sOut )
+1 -1
View File
@@ -60,7 +60,6 @@ public:
void ResetState();
/* Run an expression in the global environment, returning the given type. */
float RunExpressionF( const CString &str );
int RunExpressionI( const CString &str );
bool RunExpressionS( const CString &str, CString &sOut );
@@ -105,6 +104,7 @@ namespace LuaHelpers
/* Run an expression in the global environment, returning the given type. */
bool RunExpressionB( const CString &str );
float RunExpressionF( const CString &str );
template<class T>
void ReadArrayFromTable( vector<T> &aOut, lua_State *L )
+1 -1
View File
@@ -29,7 +29,7 @@ void RollingNumbers::LoadFromNode( const CString& sDir, const XNode* pNode )
CString sTargetNumber;
if( pNode->GetAttrValue( "TargetNumber", sTargetNumber ) )
{
float fTargetNumber = LUA->RunExpressionF(sTargetNumber);
float fTargetNumber = LuaHelpers::RunExpressionF(sTargetNumber);
SetTargetNumber( fTargetNumber );
}
+1 -1
View File
@@ -719,7 +719,7 @@ float ThemeManager::GetMetricF( const CString &sClassName, const CString &sValue
LUA->PrepareExpression( sValue );
return LUA->RunExpressionF( sValue );
return LuaHelpers::RunExpressionF( sValue );
}
// #include "LuaManager.h"