From be15f6800ec03bc1d5f229a2f22423e141dfa8aa Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 25 Feb 2004 23:58:47 +0000 Subject: [PATCH] add Lua::GetStack lua MonthOfYear: return 1..12 instead of 0..11 --- stepmania/src/LuaHelpers.cpp | 13 ++++++++++++- stepmania/src/LuaHelpers.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/stepmania/src/LuaHelpers.cpp b/stepmania/src/LuaHelpers.cpp index 5547f1efe6..4cfaf6a915 100644 --- a/stepmania/src/LuaHelpers.cpp +++ b/stepmania/src/LuaHelpers.cpp @@ -76,6 +76,17 @@ void Lua::PopStack( lua_State *L, CString &out ) lua_pop( L, -1 ); } +bool Lua::GetStack( lua_State *L, int pos, int &out ) +{ + if( pos < 0 ) + pos = lua_gettop(L) - pos - 1; + if( pos < 1 ) + return false; + + out = (int) lua_tonumber( L, pos ); + return true; +} + void LoadFromString( lua_State *L, const CString &str ) { ChunkReaderData data; @@ -171,7 +182,7 @@ LuaFunctionList::LuaFunctionList( CString name_, lua_CFunction func_ ) } -LuaFunction_NoArgs( MonthOfYear, GetLocalTime().tm_mon ); +LuaFunction_NoArgs( MonthOfYear, GetLocalTime().tm_mon+1 ); LuaFunction_NoArgs( DayOfMonth, GetLocalTime().tm_mday ); LuaFunction_NoArgs( Hour, GetLocalTime().tm_hour ); LuaFunction_NoArgs( Minute, GetLocalTime().tm_min ); diff --git a/stepmania/src/LuaHelpers.h b/stepmania/src/LuaHelpers.h index 69042f6b04..c9bbe67480 100644 --- a/stepmania/src/LuaHelpers.h +++ b/stepmania/src/LuaHelpers.h @@ -16,6 +16,7 @@ namespace Lua void PushStack( lua_State *L, void *out ); void PushStack( lua_State *L, const CString &out ); void PopStack( lua_State *L, CString &out ); + bool GetStack( lua_State *L, int pos, int &out ); }; #endif