summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mainmenu.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-12-29 21:23:51 -0500
committerkwolekr <kwolekr@minetest.net>2014-12-29 21:23:51 -0500
commitca89e63b27a2548a7615fcf4943c22f88818f6eb (patch)
tree6e8f0b35321e580d6080a128839406b748b8fc9d /src/script/lua_api/l_mainmenu.cpp
parent5e2753c712e8f65fa50f4889fc1422393ba21413 (diff)
downloadminetest-ca89e63b27a2548a7615fcf4943c22f88818f6eb.tar.gz
minetest-ca89e63b27a2548a7615fcf4943c22f88818f6eb.tar.bz2
minetest-ca89e63b27a2548a7615fcf4943c22f88818f6eb.zip
Add core.get_mapgen_names() to Main Menu API (and use it)
Also rewrite mapgen registration for static initialization
Diffstat (limited to 'src/script/lua_api/l_mainmenu.cpp')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 1760d2794..572b8efc8 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "convert_json.h"
#include "serverlist.h"
+#include "emerge.h"
#include "sound.h"
#include "settings.h"
#include "main.h" // for g_settings
@@ -689,6 +690,25 @@ int ModApiMainMenu::l_set_topleft_text(lua_State *L)
}
/******************************************************************************/
+int ModApiMainMenu::l_get_mapgen_names(lua_State *L)
+{
+ lua_newtable(L);
+
+ std::list<const char *> names;
+ EmergeManager::getMapgenNames(names);
+
+ int i = 1;
+ for (std::list<const char *>::const_iterator
+ it = names.begin(); it != names.end(); ++it) {
+ lua_pushstring(L, *it);
+ lua_rawseti(L, -2, i++);
+ }
+
+ return 1;
+}
+
+
+/******************************************************************************/
int ModApiMainMenu::l_get_modpath(lua_State *L)
{
std::string modpath
@@ -1107,6 +1127,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(delete_favorite);
API_FCT(set_background);
API_FCT(set_topleft_text);
+ API_FCT(get_mapgen_names);
API_FCT(get_modpath);
API_FCT(get_gamepath);
API_FCT(get_texturepath);
@@ -1137,6 +1158,7 @@ void ModApiMainMenu::InitializeAsync(AsyncEngine& engine)
ASYNC_API_FCT(get_worlds);
ASYNC_API_FCT(get_games);
ASYNC_API_FCT(get_favorites);
+ ASYNC_API_FCT(get_mapgen_names);
ASYNC_API_FCT(get_modpath);
ASYNC_API_FCT(get_gamepath);
ASYNC_API_FCT(get_texturepath);