From c13accadc0df5acd99d6093582a659104f11fd76 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 16 Feb 2005 21:20:33 +0000 Subject: [PATCH] evaluate PlayerNumber as a lua expression --- stepmania/src/LuaManager.cpp | 5 +++++ stepmania/src/LuaManager.h | 1 + stepmania/src/ScoreDisplayCalories.cpp | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index e35addf1ee..176692f016 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -359,6 +359,11 @@ float LuaManager::RunExpressionF( const CString &str ) return result; } +int LuaManager::RunExpressionI( const CString &str ) +{ + return (int)RunExpressionF(str); +} + bool LuaManager::RunExpressionS( const CString &str, CString &sOut ) { if( !RunExpression( str ) ) diff --git a/stepmania/src/LuaManager.h b/stepmania/src/LuaManager.h index 55117d3929..04bd8a0d33 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -30,6 +30,7 @@ public: /* Run an expression in the global environment, returning the given type. */ bool RunExpressionB( const CString &str ); float RunExpressionF( const CString &str ); + int RunExpressionI( const CString &str ); bool RunExpressionS( const CString &str, CString &sOut ); /* If sStr begins with @, evaluate the rest as an expression and store the result over sStr. */ diff --git a/stepmania/src/ScoreDisplayCalories.cpp b/stepmania/src/ScoreDisplayCalories.cpp index 544ce3c75d..33837ae256 100644 --- a/stepmania/src/ScoreDisplayCalories.cpp +++ b/stepmania/src/ScoreDisplayCalories.cpp @@ -27,8 +27,12 @@ void ScoreDisplayCalories::LoadFromNode( const CString& sDir, const XNode* pNode { RollingNumbers::LoadFromNode( sDir, pNode ); - bool b = pNode->GetAttrValue( "PlayerNumber", (int&)m_PlayerNumber ); - ASSERT( b ); + { + CString sPlayerNumber; + bool b = pNode->GetAttrValue( "PlayerNumber", sPlayerNumber ); + ASSERT( b ); + m_PlayerNumber = (PlayerNumber)LUA->RunExpressionI(sPlayerNumber); + } m_sMessageOnStep = ssprintf("StepP%d",m_PlayerNumber+1);