From 7e4a302ba4cf3cffd3876fc7642598689ce1629d Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 16 Feb 2005 21:21:36 +0000 Subject: [PATCH] fix precision loss (might be important someday) --- stepmania/src/LuaManager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index 176692f016..b82c592ba5 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -361,7 +361,17 @@ float LuaManager::RunExpressionF( const CString &str ) int LuaManager::RunExpressionI( const CString &str ) { - return (int)RunExpressionF(str); + if( !RunExpression( str ) ) + return 0; + + /* Don't accept a function as a return value. */ + if( lua_isfunction( L, -1 ) ) + RageException::Throw( "result is a function; did you forget \"()\"?" ); + + int result = (int) lua_tonumber( L, -1 ); + lua_pop( L, -1 ); + + return result; } bool LuaManager::RunExpressionS( const CString &str, CString &sOut )