mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Add version API
This commit is contained in:
parent
70e2df4f86
commit
7607b0ac20
@ -76,8 +76,9 @@ return {
|
|||||||
caption = fgettext("Credits"),
|
caption = fgettext("Credits"),
|
||||||
cbf_formspec = function(tabview, name, tabdata)
|
cbf_formspec = function(tabview, name, tabdata)
|
||||||
local logofile = defaulttexturedir .. "logo.png"
|
local logofile = defaulttexturedir .. "logo.png"
|
||||||
|
local version = core.get_version()
|
||||||
return "image[0.5,1;" .. core.formspec_escape(logofile) .. "]" ..
|
return "image[0.5,1;" .. core.formspec_escape(logofile) .. "]" ..
|
||||||
"label[0.5,3.2;Minetest " .. core.get_version() .. "]" ..
|
"label[0.5,3.2;" .. version.project .. " " .. version.string .. "]" ..
|
||||||
"label[0.5,3.5;http://minetest.net]" ..
|
"label[0.5,3.5;http://minetest.net]" ..
|
||||||
"tablecolumns[color;text]" ..
|
"tablecolumns[color;text]" ..
|
||||||
"tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
|
"tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
|
||||||
|
@ -1908,6 +1908,17 @@ Helper functions
|
|||||||
* nil: return all entries,
|
* nil: return all entries,
|
||||||
* true: return only subdirectory names, or
|
* true: return only subdirectory names, or
|
||||||
* false: return only file names.
|
* false: return only file names.
|
||||||
|
* `minetest.get_version()`: returns a table containing components of the
|
||||||
|
engine version. Components:
|
||||||
|
* `project`: Name of the project, eg, "Minetest"
|
||||||
|
* `string`: Simple version, eg, "1.2.3-dev"
|
||||||
|
* `hash`: Full git version (only set if available), eg, "1.2.3-dev-01234567-dirty"
|
||||||
|
Use this for informational purposes only. The information in the returned
|
||||||
|
table does not represent the capabilities of the engine, nor is it
|
||||||
|
reliable or verifyable. Compatible forks will have a different name and
|
||||||
|
version entirely. To check for the presence of engine features, test
|
||||||
|
whether the functions exported by the wanted features exist. For example:
|
||||||
|
`if core.nodeupdate then ... end`.
|
||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
* `minetest.debug(...)`
|
* `minetest.debug(...)`
|
||||||
|
@ -955,13 +955,6 @@ int ModApiMainMenu::l_show_file_open_dialog(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
int ModApiMainMenu::l_get_version(lua_State *L)
|
|
||||||
{
|
|
||||||
lua_pushstring(L, g_version_string);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
int ModApiMainMenu::l_sound_play(lua_State *L)
|
int ModApiMainMenu::l_sound_play(lua_State *L)
|
||||||
{
|
{
|
||||||
@ -1157,7 +1150,6 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
|
|||||||
API_FCT(extract_zip);
|
API_FCT(extract_zip);
|
||||||
API_FCT(get_mainmenu_path);
|
API_FCT(get_mainmenu_path);
|
||||||
API_FCT(show_file_open_dialog);
|
API_FCT(show_file_open_dialog);
|
||||||
API_FCT(get_version);
|
|
||||||
API_FCT(download_file);
|
API_FCT(download_file);
|
||||||
API_FCT(get_modstore_details);
|
API_FCT(get_modstore_details);
|
||||||
API_FCT(get_modstore_list);
|
API_FCT(get_modstore_list);
|
||||||
@ -1188,7 +1180,6 @@ void ModApiMainMenu::InitializeAsync(AsyncEngine& engine)
|
|||||||
ASYNC_API_FCT(delete_dir);
|
ASYNC_API_FCT(delete_dir);
|
||||||
ASYNC_API_FCT(copy_dir);
|
ASYNC_API_FCT(copy_dir);
|
||||||
//ASYNC_API_FCT(extract_zip); //TODO remove dependency to GuiEngine
|
//ASYNC_API_FCT(extract_zip); //TODO remove dependency to GuiEngine
|
||||||
ASYNC_API_FCT(get_version);
|
|
||||||
ASYNC_API_FCT(download_file);
|
ASYNC_API_FCT(download_file);
|
||||||
ASYNC_API_FCT(get_modstore_details);
|
ASYNC_API_FCT(get_modstore_details);
|
||||||
ASYNC_API_FCT(get_modstore_list);
|
ASYNC_API_FCT(get_modstore_list);
|
||||||
|
@ -79,8 +79,6 @@ private:
|
|||||||
|
|
||||||
static int l_delete_favorite(lua_State *L);
|
static int l_delete_favorite(lua_State *L);
|
||||||
|
|
||||||
static int l_get_version(lua_State *L);
|
|
||||||
|
|
||||||
static int l_sound_play(lua_State *L);
|
static int l_sound_play(lua_State *L);
|
||||||
|
|
||||||
static int l_sound_stop(lua_State *L);
|
static int l_sound_stop(lua_State *L);
|
||||||
|
@ -33,8 +33,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "util/auth.h"
|
#include "util/auth.h"
|
||||||
#include "util/base64.h"
|
#include "util/base64.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "version.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
// log([level,] text)
|
// log([level,] text)
|
||||||
// Writes a line to the logger.
|
// Writes a line to the logger.
|
||||||
// The one-argument version logs to infostream.
|
// The one-argument version logs to infostream.
|
||||||
@ -302,12 +305,14 @@ int ModApiUtil::l_is_yes(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get_builtin_path()
|
||||||
int ModApiUtil::l_get_builtin_path(lua_State *L)
|
int ModApiUtil::l_get_builtin_path(lua_State *L)
|
||||||
{
|
{
|
||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
|
||||||
std::string path = porting::path_share + DIR_DELIM + "builtin";
|
std::string path = porting::path_share + DIR_DELIM + "builtin";
|
||||||
lua_pushstring(L, path.c_str());
|
lua_pushstring(L, path.c_str());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,6 +465,26 @@ int ModApiUtil::l_request_insecure_environment(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get_version()
|
||||||
|
int ModApiUtil::l_get_version(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_createtable(L, 0, 3);
|
||||||
|
int table = lua_gettop(L);
|
||||||
|
|
||||||
|
lua_pushstring(L, PROJECT_NAME_C);
|
||||||
|
lua_setfield(L, table, "project");
|
||||||
|
|
||||||
|
lua_pushstring(L, g_version_string);
|
||||||
|
lua_setfield(L, table, "string");
|
||||||
|
|
||||||
|
if (strcmp(g_version_string, g_version_hash)) {
|
||||||
|
lua_pushstring(L, g_version_hash);
|
||||||
|
lua_setfield(L, table, "hash");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModApiUtil::Initialize(lua_State *L, int top)
|
void ModApiUtil::Initialize(lua_State *L, int top)
|
||||||
{
|
{
|
||||||
@ -496,6 +521,8 @@ void ModApiUtil::Initialize(lua_State *L, int top)
|
|||||||
|
|
||||||
API_FCT(encode_base64);
|
API_FCT(encode_base64);
|
||||||
API_FCT(decode_base64);
|
API_FCT(decode_base64);
|
||||||
|
|
||||||
|
API_FCT(get_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
||||||
@ -525,5 +552,7 @@ void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
|||||||
|
|
||||||
ASYNC_API_FCT(encode_base64);
|
ASYNC_API_FCT(encode_base64);
|
||||||
ASYNC_API_FCT(decode_base64);
|
ASYNC_API_FCT(decode_base64);
|
||||||
|
|
||||||
|
ASYNC_API_FCT(get_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,9 @@ private:
|
|||||||
// decode_base64(string)
|
// decode_base64(string)
|
||||||
static int l_decode_base64(lua_State *L);
|
static int l_decode_base64(lua_State *L);
|
||||||
|
|
||||||
|
// get_version()
|
||||||
|
static int l_get_version(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize(lua_State *L, int top);
|
static void Initialize(lua_State *L, int top);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user