From bf315c05f17549d37d7b4c4bd7938df0b5b32c5a Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 2 Nov 2016 11:36:58 -0500 Subject: Add minetest.get_server_uptime() function to Lua API (#4702) Add minetest.get_server_uptime() function to Lua API --- src/script/lua_api/l_server.cpp | 10 ++++++++++ src/script/lua_api/l_server.h | 3 +++ 2 files changed, 13 insertions(+) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index 95e5da07f..b6d44e0ff 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -45,6 +45,15 @@ int ModApiServer::l_get_server_status(lua_State *L) return 1; } +// get_server_uptime() +int ModApiServer::l_get_server_uptime(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + lua_pushnumber(L, getServer(L)->getUptime()); + return 1; +} + + // print(text) int ModApiServer::l_print(lua_State *L) { @@ -507,6 +516,7 @@ void ModApiServer::Initialize(lua_State *L, int top) { API_FCT(request_shutdown); API_FCT(get_server_status); + API_FCT(get_server_uptime); API_FCT(get_worldpath); API_FCT(is_singleplayer); diff --git a/src/script/lua_api/l_server.h b/src/script/lua_api/l_server.h index 06a5ddc24..1ad46d440 100644 --- a/src/script/lua_api/l_server.h +++ b/src/script/lua_api/l_server.h @@ -30,6 +30,9 @@ private: // get_server_status() static int l_get_server_status(lua_State *L); + // get_server_uptime() + static int l_get_server_uptime(lua_State *L); + // get_worldpath() static int l_get_worldpath(lua_State *L); -- cgit v1.2.3