add Lua::GetStack

lua MonthOfYear: return 1..12 instead of 0..11
This commit is contained in:
Glenn Maynard
2004-02-25 23:58:47 +00:00
parent 572a914f9f
commit be15f6800e
2 changed files with 13 additions and 1 deletions
+12 -1
View File
@@ -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 );
+1
View File
@@ -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