aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cpp_api/s_base.cpp2
-rw-r--r--src/script/lua_api/l_base.cpp2
-rw-r--r--src/script/lua_api/l_mainmenu.cpp120
-rw-r--r--src/script/lua_api/l_mainmenu.h5
-rw-r--r--src/script/lua_api/l_storage.cpp2
-rw-r--r--src/script/scripting_mainmenu.cpp2
6 files changed, 104 insertions, 29 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp
index 571bac611..54ff8c495 100644
--- a/src/script/cpp_api/s_base.cpp
+++ b/src/script/cpp_api/s_base.cpp
@@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_converter.h"
#include "serverobject.h"
#include "filesys.h"
-#include "mods.h"
+#include "content/mods.h"
#include "porting.h"
#include "util/string.h"
#include "server.h"
diff --git a/src/script/lua_api/l_base.cpp b/src/script/lua_api/l_base.cpp
index 5d7ba9640..8ab0a20b6 100644
--- a/src/script/lua_api/l_base.cpp
+++ b/src/script/lua_api/l_base.cpp
@@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_base.h"
#include "lua_api/l_internal.h"
#include "cpp_api/s_base.h"
-#include <mods.h>
+#include "content/mods.h"
#include <server.h>
ScriptApiBase *ModApiBase::getScriptApiBase(lua_State *L)
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 027b7b0f8..241427709 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -25,11 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gui/guiMainMenu.h"
#include "gui/guiKeyChangeMenu.h"
#include "gui/guiPathSelectMenu.h"
-#include "subgame.h"
#include "version.h"
#include "porting.h"
#include "filesys.h"
#include "convert_json.h"
+#include "content/packages.h"
+#include "content/content.h"
+#include "content/subgames.h"
#include "serverlist.h"
#include "mapgen/mapgen.h"
#include "settings.h"
@@ -449,6 +451,10 @@ int ModApiMainMenu::l_get_games(lua_State *L)
lua_pushstring(L, game.path.c_str());
lua_settable(L, top_lvl2);
+ lua_pushstring(L, "type");
+ lua_pushstring(L, "game");
+ lua_settable(L, top_lvl2);
+
lua_pushstring(L, "gamemods_path");
lua_pushstring(L, game.gamemods_path.c_str());
lua_settable(L, top_lvl2);
@@ -457,6 +463,10 @@ int ModApiMainMenu::l_get_games(lua_State *L)
lua_pushstring(L, game.name.c_str());
lua_settable(L, top_lvl2);
+ lua_pushstring(L, "author");
+ lua_pushstring(L, game.author.c_str());
+ lua_settable(L, top_lvl2);
+
lua_pushstring(L, "menuicon_path");
lua_pushstring(L, game.menuicon_path.c_str());
lua_settable(L, top_lvl2);
@@ -479,47 +489,56 @@ int ModApiMainMenu::l_get_games(lua_State *L)
}
/******************************************************************************/
-int ModApiMainMenu::l_get_mod_info(lua_State *L)
+int ModApiMainMenu::l_get_content_info(lua_State *L)
{
std::string path = luaL_checkstring(L, 1);
- ModSpec spec;
+ ContentSpec spec;
spec.path = path;
- parseModContents(spec);
+ parseContentInfo(spec);
lua_newtable(L);
lua_pushstring(L, spec.name.c_str());
lua_setfield(L, -2, "name");
- lua_pushstring(L, spec.is_modpack ? "modpack" : "mod");
+ lua_pushstring(L, spec.type.c_str());
lua_setfield(L, -2, "type");
+ lua_pushstring(L, spec.author.c_str());
+ lua_setfield(L, -2, "author");
+
lua_pushstring(L, spec.desc.c_str());
lua_setfield(L, -2, "description");
lua_pushstring(L, spec.path.c_str());
lua_setfield(L, -2, "path");
- // Dependencies
- lua_newtable(L);
- int i = 1;
- for (const auto &dep : spec.depends) {
- lua_pushstring(L, dep.c_str());
- lua_rawseti(L, -2, i);
- i++;
- }
- lua_setfield(L, -2, "depends");
+ if (spec.type == "mod") {
+ ModSpec spec;
+ spec.path = path;
+ parseModContents(spec);
- // Optional Dependencies
- lua_newtable(L);
- i = 1;
- for (const auto &dep : spec.optdepends) {
- lua_pushstring(L, dep.c_str());
- lua_rawseti(L, -2, i);
- i++;
+ // Dependencies
+ lua_newtable(L);
+ int i = 1;
+ for (const auto &dep : spec.depends) {
+ lua_pushstring(L, dep.c_str());
+ lua_rawseti(L, -2, i);
+ i++;
+ }
+ lua_setfield(L, -2, "depends");
+
+ // Optional Dependencies
+ lua_newtable(L);
+ i = 1;
+ for (const auto &dep : spec.optdepends) {
+ lua_pushstring(L, dep.c_str());
+ lua_rawseti(L, -2, i);
+ i++;
+ }
+ lua_setfield(L, -2, "optional_depends");
}
- lua_setfield(L, -2, "optional_depends");
return 1;
}
@@ -838,6 +857,10 @@ bool ModApiMainMenu::isMinetestPath(std::string path)
if (fs::PathStartsWith(path,fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "mods")))
return true;
+ /* mods */
+ if (fs::PathStartsWith(path,fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "textures")))
+ return true;
+
/* worlds */
if (fs::PathStartsWith(path,fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "worlds")))
return true;
@@ -972,6 +995,54 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
return 1;
}
+int ModApiMainMenu::l_get_package_list(lua_State *L)
+{
+ std::string url = g_settings->get("contentdb_url");
+ std::vector<Package> packages = getPackagesFromURL(url + "/packages/");
+
+ // Make table
+ lua_newtable(L);
+ int top = lua_gettop(L);
+ unsigned int index = 1;
+
+ // Fill table
+ for (const auto &package : packages) {
+ lua_pushnumber(L, index);
+ lua_newtable(L);
+
+ int top_lvl2 = lua_gettop(L);
+
+ lua_pushstring(L, "name");
+ lua_pushstring(L, package.name.c_str());
+ lua_settable (L, top_lvl2);
+
+ lua_pushstring(L, "title");
+ lua_pushstring(L, package.title.c_str());
+ lua_settable (L, top_lvl2);
+
+ lua_pushstring(L, "author");
+ lua_pushstring(L, package.author.c_str());
+ lua_settable (L, top_lvl2);
+
+ lua_pushstring(L, "type");
+ lua_pushstring(L, package.type.c_str());
+ lua_settable (L, top_lvl2);
+
+ lua_pushstring(L, "short_description");
+ lua_pushstring(L, package.shortDesc.c_str());
+ lua_settable (L, top_lvl2);
+
+ lua_pushstring(L, "url");
+ lua_pushstring(L, package.url.c_str());
+ lua_settable (L, top_lvl2);
+
+ lua_settable(L, top);
+ index++;
+ }
+
+ return 1;
+}
+
/******************************************************************************/
int ModApiMainMenu::l_get_min_supp_proto(lua_State *L)
{
@@ -1015,7 +1086,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(get_table_index);
API_FCT(get_worlds);
API_FCT(get_games);
- API_FCT(get_mod_info);
+ API_FCT(get_content_info);
API_FCT(start);
API_FCT(close);
API_FCT(get_favorites);
@@ -1042,6 +1113,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(get_video_drivers);
API_FCT(get_video_modes);
API_FCT(get_screen_info);
+ API_FCT(get_package_list);
API_FCT(get_min_supp_proto);
API_FCT(get_max_supp_proto);
API_FCT(do_async_callback);
@@ -1050,7 +1122,6 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
/******************************************************************************/
void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
{
-
API_FCT(get_worlds);
API_FCT(get_games);
API_FCT(get_favorites);
@@ -1066,4 +1137,5 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
//API_FCT(extract_zip); //TODO remove dependency to GuiEngine
API_FCT(download_file);
//API_FCT(gettext); (gettext lib isn't threadsafe)
+ API_FCT(get_package_list);
}
diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h
index 2faeaf63e..b08a5bc01 100644
--- a/src/script/lua_api/l_mainmenu.h
+++ b/src/script/lua_api/l_mainmenu.h
@@ -83,7 +83,7 @@ private:
static int l_get_games(lua_State *L);
- static int l_get_mod_info(lua_State *L);
+ static int l_get_content_info(lua_State *L);
//gui
@@ -133,6 +133,9 @@ private:
static int l_get_video_modes(lua_State *L);
+ //content store
+ static int l_get_package_list(lua_State *L);
+
//version compatibility
static int l_get_min_supp_proto(lua_State *L);
diff --git a/src/script/lua_api/l_storage.cpp b/src/script/lua_api/l_storage.cpp
index 4c6b2a182..01810ca8b 100644
--- a/src/script/lua_api/l_storage.cpp
+++ b/src/script/lua_api/l_storage.cpp
@@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_storage.h"
#include "l_internal.h"
-#include "mods.h"
+#include "content/mods.h"
#include "server.h"
int ModApiStorage::l_get_mod_storage(lua_State *L)
diff --git a/src/script/scripting_mainmenu.cpp b/src/script/scripting_mainmenu.cpp
index 0ff60951b..b6068439a 100644
--- a/src/script/scripting_mainmenu.cpp
+++ b/src/script/scripting_mainmenu.cpp
@@ -18,7 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "scripting_mainmenu.h"
-#include "mods.h"
+#include "content/mods.h"
#include "cpp_api/s_internal.h"
#include "lua_api/l_base.h"
#include "lua_api/l_mainmenu.h"