Add minetest.get_server_uptime() function to Lua API (#4702)
Add minetest.get_server_uptime() function to Lua API
This commit is contained in:
parent
7607b0ac20
commit
bf315c05f1
|
@ -2448,6 +2448,7 @@ These functions return the leftover itemstack.
|
||||||
* `minetest.request_shutdown([message],[reconnect])`: request for server shutdown. Will display `message` to clients,
|
* `minetest.request_shutdown([message],[reconnect])`: request for server shutdown. Will display `message` to clients,
|
||||||
and `reconnect` == true displays a reconnect button.
|
and `reconnect` == true displays a reconnect button.
|
||||||
* `minetest.get_server_status()`: returns server status string
|
* `minetest.get_server_status()`: returns server status string
|
||||||
|
* `minetest.get_server_uptime()`: returns the server uptime in seconds
|
||||||
|
|
||||||
### Bans
|
### Bans
|
||||||
* `minetest.get_ban_list()`: returns the ban list (same as `minetest.get_ban_description("")`)
|
* `minetest.get_ban_list()`: returns the ban list (same as `minetest.get_ban_description("")`)
|
||||||
|
|
|
@ -45,6 +45,15 @@ int ModApiServer::l_get_server_status(lua_State *L)
|
||||||
return 1;
|
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)
|
// print(text)
|
||||||
int ModApiServer::l_print(lua_State *L)
|
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(request_shutdown);
|
||||||
API_FCT(get_server_status);
|
API_FCT(get_server_status);
|
||||||
|
API_FCT(get_server_uptime);
|
||||||
API_FCT(get_worldpath);
|
API_FCT(get_worldpath);
|
||||||
API_FCT(is_singleplayer);
|
API_FCT(is_singleplayer);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@ private:
|
||||||
// get_server_status()
|
// get_server_status()
|
||||||
static int l_get_server_status(lua_State *L);
|
static int l_get_server_status(lua_State *L);
|
||||||
|
|
||||||
|
// get_server_uptime()
|
||||||
|
static int l_get_server_uptime(lua_State *L);
|
||||||
|
|
||||||
// get_worldpath()
|
// get_worldpath()
|
||||||
static int l_get_worldpath(lua_State *L);
|
static int l_get_worldpath(lua_State *L);
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,7 @@ public:
|
||||||
|
|
||||||
// Connection must be locked when called
|
// Connection must be locked when called
|
||||||
std::wstring getStatusString();
|
std::wstring getStatusString();
|
||||||
|
inline double getUptime() const { return m_uptime.m_value; }
|
||||||
|
|
||||||
// read shutdown state
|
// read shutdown state
|
||||||
inline bool getShutdownRequested() const { return m_shutdown_requested; }
|
inline bool getShutdownRequested() const { return m_shutdown_requested; }
|
||||||
|
|
Loading…
Reference in New Issue