3 Copyright (C) 2013 sapier
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "lua_api/l_mainmenu.h"
21 #include "lua_api/l_internal.h"
22 #include "common/c_content.h"
23 #include "guiEngine.h"
24 #include "guiMainMenu.h"
25 #include "guiKeyChangeMenu.h"
26 #include "guiFileSelectMenu.h"
30 #include "convert_json.h"
31 #include "serverlist.h"
34 #include "main.h" // for g_settings
36 #include <IFileArchive.h>
37 #include <IFileSystem.h>
39 /******************************************************************************/
40 std::string ModApiMainMenu::getTextData(lua_State *L, std::string name)
42 lua_getglobal(L, "gamedata");
44 lua_getfield(L, -1, name.c_str());
49 return luaL_checkstring(L, -1);
52 /******************************************************************************/
53 int ModApiMainMenu::getIntegerData(lua_State *L, std::string name,bool& valid)
55 lua_getglobal(L, "gamedata");
57 lua_getfield(L, -1, name.c_str());
59 if(lua_isnil(L, -1)) {
65 return luaL_checkinteger(L, -1);
68 /******************************************************************************/
69 int ModApiMainMenu::getBoolData(lua_State *L, std::string name,bool& valid)
71 lua_getglobal(L, "gamedata");
73 lua_getfield(L, -1, name.c_str());
75 if(lua_isnil(L, -1)) {
81 return lua_toboolean(L, -1);
84 /******************************************************************************/
85 int ModApiMainMenu::l_update_formspec(lua_State *L)
87 GUIEngine* engine = getGuiEngine(L);
90 if (engine->m_startgame)
94 std::string formspec(luaL_checkstring(L, 1));
96 if (engine->m_formspecgui != 0) {
97 engine->m_formspecgui->setForm(formspec);
103 /******************************************************************************/
104 int ModApiMainMenu::l_start(lua_State *L)
106 GUIEngine* engine = getGuiEngine(L);
109 //update c++ gamedata from lua table
114 engine->m_data->selected_world = getIntegerData(L, "selected_world",valid) -1;
115 engine->m_data->simple_singleplayer_mode = getBoolData(L,"singleplayer",valid);
116 engine->m_data->name = getTextData(L,"playername");
117 engine->m_data->password = getTextData(L,"password");
118 engine->m_data->address = getTextData(L,"address");
119 engine->m_data->port = getTextData(L,"port");
120 engine->m_data->serverdescription = getTextData(L,"serverdescription");
121 engine->m_data->servername = getTextData(L,"servername");
123 //close menu next time
124 engine->m_startgame = true;
128 /******************************************************************************/
129 int ModApiMainMenu::l_close(lua_State *L)
131 GUIEngine* engine = getGuiEngine(L);
134 engine->m_kill = true;
138 /******************************************************************************/
139 int ModApiMainMenu::l_set_background(lua_State *L)
141 GUIEngine* engine = getGuiEngine(L);
144 std::string backgroundlevel(luaL_checkstring(L, 1));
145 std::string texturename(luaL_checkstring(L, 2));
149 if (backgroundlevel == "background") {
150 retval |= engine->setTexture(TEX_LAYER_BACKGROUND,texturename);
153 if (backgroundlevel == "overlay") {
154 retval |= engine->setTexture(TEX_LAYER_OVERLAY,texturename);
157 if (backgroundlevel == "header") {
158 retval |= engine->setTexture(TEX_LAYER_HEADER,texturename);
161 if (backgroundlevel == "footer") {
162 retval |= engine->setTexture(TEX_LAYER_FOOTER,texturename);
165 lua_pushboolean(L,retval);
169 /******************************************************************************/
170 int ModApiMainMenu::l_set_clouds(lua_State *L)
172 GUIEngine* engine = getGuiEngine(L);
175 bool value = lua_toboolean(L,1);
177 engine->m_clouds_enabled = value;
182 /******************************************************************************/
183 int ModApiMainMenu::l_get_textlist_index(lua_State *L)
185 GUIEngine* engine = getGuiEngine(L);
188 std::string listboxname(luaL_checkstring(L, 1));
190 int selection = engine->m_menu->getListboxIndex(listboxname);
195 lua_pushinteger(L, selection);
199 /******************************************************************************/
200 int ModApiMainMenu::l_get_worlds(lua_State *L)
202 GUIEngine* engine = getGuiEngine(L);
205 std::vector<WorldSpec> worlds = getAvailableWorlds();
208 int top = lua_gettop(L);
209 unsigned int index = 1;
211 for (unsigned int i = 0; i < worlds.size(); i++)
213 lua_pushnumber(L,index);
216 int top_lvl2 = lua_gettop(L);
218 lua_pushstring(L,"path");
219 lua_pushstring(L,worlds[i].path.c_str());
220 lua_settable(L, top_lvl2);
222 lua_pushstring(L,"name");
223 lua_pushstring(L,worlds[i].name.c_str());
224 lua_settable(L, top_lvl2);
226 lua_pushstring(L,"gameid");
227 lua_pushstring(L,worlds[i].gameid.c_str());
228 lua_settable(L, top_lvl2);
230 lua_settable(L, top);
236 /******************************************************************************/
237 int ModApiMainMenu::l_get_games(lua_State *L)
239 GUIEngine* engine = getGuiEngine(L);
242 std::vector<SubgameSpec> games = getAvailableGames();
245 int top = lua_gettop(L);
246 unsigned int index = 1;
248 for (unsigned int i = 0; i < games.size(); i++)
250 lua_pushnumber(L,index);
252 int top_lvl2 = lua_gettop(L);
254 lua_pushstring(L,"id");
255 lua_pushstring(L,games[i].id.c_str());
256 lua_settable(L, top_lvl2);
258 lua_pushstring(L,"path");
259 lua_pushstring(L,games[i].path.c_str());
260 lua_settable(L, top_lvl2);
262 lua_pushstring(L,"gamemods_path");
263 lua_pushstring(L,games[i].gamemods_path.c_str());
264 lua_settable(L, top_lvl2);
266 lua_pushstring(L,"name");
267 lua_pushstring(L,games[i].name.c_str());
268 lua_settable(L, top_lvl2);
270 lua_pushstring(L,"menuicon_path");
271 lua_pushstring(L,games[i].menuicon_path.c_str());
272 lua_settable(L, top_lvl2);
274 lua_pushstring(L,"addon_mods_paths");
276 int table2 = lua_gettop(L);
277 int internal_index=1;
278 for (std::set<std::string>::iterator iter = games[i].addon_mods_paths.begin();
279 iter != games[i].addon_mods_paths.end(); iter++) {
280 lua_pushnumber(L,internal_index);
281 lua_pushstring(L,(*iter).c_str());
282 lua_settable(L, table2);
285 lua_settable(L, top_lvl2);
286 lua_settable(L, top);
291 /******************************************************************************/
292 int ModApiMainMenu::l_get_modstore_details(lua_State *L)
294 const char *modid = luaL_checkstring(L, 1);
298 std::string url = "";
300 url = g_settings->get("modstore_details_url");
302 catch(SettingNotFoundException &e) {
307 size_t idpos = url.find("*");
309 url.insert(idpos,modid);
311 details = getModstoreUrl(url);
313 ModStoreModDetails current_mod = readModStoreModDetails(details);
315 if ( current_mod.valid) {
317 int top = lua_gettop(L);
319 lua_pushstring(L,"id");
320 lua_pushnumber(L,current_mod.id);
321 lua_settable(L, top);
323 lua_pushstring(L,"title");
324 lua_pushstring(L,current_mod.title.c_str());
325 lua_settable(L, top);
327 lua_pushstring(L,"basename");
328 lua_pushstring(L,current_mod.basename.c_str());
329 lua_settable(L, top);
331 lua_pushstring(L,"description");
332 lua_pushstring(L,current_mod.description.c_str());
333 lua_settable(L, top);
335 lua_pushstring(L,"author");
336 lua_pushstring(L,current_mod.author.username.c_str());
337 lua_settable(L, top);
339 lua_pushstring(L,"download_url");
340 lua_pushstring(L,current_mod.versions[0].file.c_str());
341 lua_settable(L, top);
343 lua_pushstring(L,"screenshot_url");
344 lua_pushstring(L,current_mod.titlepic.file.c_str());
345 lua_settable(L, top);
347 lua_pushstring(L,"license");
348 lua_pushstring(L,current_mod.license.shortinfo.c_str());
349 lua_settable(L, top);
351 lua_pushstring(L,"rating");
352 lua_pushnumber(L,current_mod.rating);
353 lua_settable(L, top);
364 /******************************************************************************/
365 int ModApiMainMenu::l_get_modstore_list(lua_State *L)
367 GUIEngine* engine = getGuiEngine(L);
370 std::string listtype = "local";
372 if (!lua_isnone(L,1)) {
373 listtype = luaL_checkstring(L,1);
376 std::string url = "";
378 url = g_settings->get("modstore_listmods_url");
380 catch(SettingNotFoundException &e) {
385 mods = getModstoreUrl(url);
387 std::vector<ModStoreMod> moddata = readModStoreList(mods);
390 int top = lua_gettop(L);
391 unsigned int index = 1;
393 for (unsigned int i = 0; i < moddata.size(); i++)
395 if (moddata[i].valid) {
396 lua_pushnumber(L,index);
399 int top_lvl2 = lua_gettop(L);
401 lua_pushstring(L,"id");
402 lua_pushnumber(L,moddata[i].id);
403 lua_settable(L, top_lvl2);
405 lua_pushstring(L,"title");
406 lua_pushstring(L,moddata[i].title.c_str());
407 lua_settable(L, top_lvl2);
409 lua_pushstring(L,"basename");
410 lua_pushstring(L,moddata[i].basename.c_str());
411 lua_settable(L, top_lvl2);
413 lua_settable(L, top);
420 /******************************************************************************/
421 int ModApiMainMenu::l_get_favorites(lua_State *L)
423 GUIEngine* engine = getGuiEngine(L);
426 std::string listtype = "local";
428 if (!lua_isnone(L,1)) {
429 listtype = luaL_checkstring(L,1);
432 std::vector<ServerListSpec> servers;
434 if(listtype == "online") {
435 servers = ServerList::getOnline();
437 servers = ServerList::getLocal();
440 servers = ServerList::getLocal();
444 int top = lua_gettop(L);
445 unsigned int index = 1;
447 for (unsigned int i = 0; i < servers.size(); i++)
449 lua_pushnumber(L,index);
452 int top_lvl2 = lua_gettop(L);
454 if (servers[i]["clients"].asString().size()) {
456 const char* clients_raw = servers[i]["clients"].asString().c_str();
458 int numbervalue = strtol(clients_raw,&endptr,10);
460 if ((*clients_raw != 0) && (*endptr == 0)) {
461 lua_pushstring(L,"clients");
462 lua_pushnumber(L,numbervalue);
463 lua_settable(L, top_lvl2);
467 if (servers[i]["clients_max"].asString().size()) {
469 const char* clients_max_raw = servers[i]["clients_max"].asString().c_str();
471 int numbervalue = strtol(clients_max_raw,&endptr,10);
473 if ((*clients_max_raw != 0) && (*endptr == 0)) {
474 lua_pushstring(L,"clients_max");
475 lua_pushnumber(L,numbervalue);
476 lua_settable(L, top_lvl2);
480 if (servers[i]["version"].asString().size()) {
481 lua_pushstring(L,"version");
482 lua_pushstring(L,servers[i]["version"].asString().c_str());
483 lua_settable(L, top_lvl2);
486 if (servers[i]["password"].asString().size()) {
487 lua_pushstring(L,"password");
488 lua_pushboolean(L,true);
489 lua_settable(L, top_lvl2);
492 if (servers[i]["creative"].asString().size()) {
493 lua_pushstring(L,"creative");
494 lua_pushboolean(L,true);
495 lua_settable(L, top_lvl2);
498 if (servers[i]["damage"].asString().size()) {
499 lua_pushstring(L,"damage");
500 lua_pushboolean(L,true);
501 lua_settable(L, top_lvl2);
504 if (servers[i]["pvp"].asString().size()) {
505 lua_pushstring(L,"pvp");
506 lua_pushboolean(L,true);
507 lua_settable(L, top_lvl2);
510 if (servers[i]["description"].asString().size()) {
511 lua_pushstring(L,"description");
512 lua_pushstring(L,servers[i]["description"].asString().c_str());
513 lua_settable(L, top_lvl2);
516 if (servers[i]["name"].asString().size()) {
517 lua_pushstring(L,"name");
518 lua_pushstring(L,servers[i]["name"].asString().c_str());
519 lua_settable(L, top_lvl2);
522 if (servers[i]["address"].asString().size()) {
523 lua_pushstring(L,"address");
524 lua_pushstring(L,servers[i]["address"].asString().c_str());
525 lua_settable(L, top_lvl2);
528 if (servers[i]["port"].asString().size()) {
529 lua_pushstring(L,"port");
530 lua_pushstring(L,servers[i]["port"].asString().c_str());
531 lua_settable(L, top_lvl2);
534 lua_settable(L, top);
540 /******************************************************************************/
541 int ModApiMainMenu::l_delete_favorite(lua_State *L)
543 GUIEngine* engine = getGuiEngine(L);
546 std::vector<ServerListSpec> servers;
548 std::string listtype = "local";
550 if (!lua_isnone(L,2)) {
551 listtype = luaL_checkstring(L,2);
554 if ((listtype != "local") &&
555 (listtype != "online"))
559 if(listtype == "online") {
560 servers = ServerList::getOnline();
562 servers = ServerList::getLocal();
565 servers = ServerList::getLocal();
568 int fav_idx = luaL_checkinteger(L,1) -1;
570 if ((fav_idx >= 0) &&
571 (fav_idx < (int) servers.size())) {
573 ServerList::deleteEntry(servers[fav_idx]);
579 /******************************************************************************/
580 int ModApiMainMenu::l_show_keys_menu(lua_State *L)
582 GUIEngine* engine = getGuiEngine(L);
585 GUIKeyChangeMenu *kmenu
586 = new GUIKeyChangeMenu( engine->m_device->getGUIEnvironment(),
589 engine->m_menumanager);
594 /******************************************************************************/
595 int ModApiMainMenu::l_create_world(lua_State *L)
597 GUIEngine* engine = getGuiEngine(L);
600 const char *name = luaL_checkstring(L, 1);
601 int gameidx = luaL_checkinteger(L,2) -1;
603 std::string path = porting::path_user + DIR_DELIM
607 std::vector<SubgameSpec> games = getAvailableGames();
609 if ((gameidx >= 0) &&
610 (gameidx < (int) games.size())) {
612 // Create world if it doesn't exist
613 if(!initializeWorld(path, games[gameidx].id)){
614 lua_pushstring(L, "Failed to initialize world");
622 lua_pushstring(L, "Invalid game index");
627 /******************************************************************************/
628 int ModApiMainMenu::l_delete_world(lua_State *L)
630 GUIEngine* engine = getGuiEngine(L);
633 int worldidx = luaL_checkinteger(L,1) -1;
635 std::vector<WorldSpec> worlds = getAvailableWorlds();
637 if ((worldidx >= 0) &&
638 (worldidx < (int) worlds.size())) {
640 WorldSpec spec = worlds[worldidx];
642 std::vector<std::string> paths;
643 paths.push_back(spec.path);
644 fs::GetRecursiveSubPaths(spec.path, paths);
647 if (!fs::DeletePaths(paths)) {
648 lua_pushstring(L, "Failed to delete world");
655 lua_pushstring(L, "Invalid world index");
660 /******************************************************************************/
661 int ModApiMainMenu::l_set_topleft_text(lua_State *L)
663 GUIEngine* engine = getGuiEngine(L);
666 std::string text = "";
668 if (!lua_isnone(L,1) && !lua_isnil(L,1))
669 text = luaL_checkstring(L, 1);
671 engine->setTopleftText(text);
675 /******************************************************************************/
676 int ModApiMainMenu::l_get_modpath(lua_State *L)
679 = fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "mods" + DIR_DELIM);
680 lua_pushstring(L, modpath.c_str());
684 /******************************************************************************/
685 int ModApiMainMenu::l_get_gamepath(lua_State *L)
688 = fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "games" + DIR_DELIM);
689 lua_pushstring(L, gamepath.c_str());
693 /******************************************************************************/
694 int ModApiMainMenu::l_get_texturepath(lua_State *L)
697 = fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "textures");
698 lua_pushstring(L, gamepath.c_str());
702 /******************************************************************************/
703 int ModApiMainMenu::l_get_dirlist(lua_State *L)
705 const char *path = luaL_checkstring(L, 1);
706 bool dironly = lua_toboolean(L, 2);
708 std::vector<fs::DirListNode> dirlist = fs::GetDirListing(path);
710 unsigned int index = 1;
712 int table = lua_gettop(L);
714 for (unsigned int i=0;i< dirlist.size(); i++) {
715 if ((dirlist[i].dir) || (dironly == false)) {
716 lua_pushnumber(L,index);
717 lua_pushstring(L,dirlist[i].name.c_str());
718 lua_settable(L, table);
726 /******************************************************************************/
727 int ModApiMainMenu::l_create_dir(lua_State *L) {
728 const char *path = luaL_checkstring(L, 1);
730 if (ModApiMainMenu::isMinetestPath(path)) {
731 lua_pushboolean(L,fs::CreateAllDirs(path));
734 lua_pushboolean(L,false);
738 /******************************************************************************/
739 int ModApiMainMenu::l_delete_dir(lua_State *L)
741 const char *path = luaL_checkstring(L, 1);
743 std::string absolute_path = fs::RemoveRelativePathComponents(path);
745 if (ModApiMainMenu::isMinetestPath(absolute_path)) {
746 lua_pushboolean(L,fs::RecursiveDelete(absolute_path));
749 lua_pushboolean(L,false);
753 /******************************************************************************/
754 int ModApiMainMenu::l_copy_dir(lua_State *L)
756 const char *source = luaL_checkstring(L, 1);
757 const char *destination = luaL_checkstring(L, 2);
759 bool keep_source = true;
761 if ((!lua_isnone(L,3)) &&
763 keep_source = lua_toboolean(L,3);
766 std::string absolute_destination = fs::RemoveRelativePathComponents(destination);
767 std::string absolute_source = fs::RemoveRelativePathComponents(source);
769 if ((ModApiMainMenu::isMinetestPath(absolute_source)) &&
770 (ModApiMainMenu::isMinetestPath(absolute_destination))) {
771 bool retval = fs::CopyDir(absolute_source,absolute_destination);
773 if (retval && (!keep_source)) {
775 retval &= fs::RecursiveDelete(absolute_source);
777 lua_pushboolean(L,retval);
780 lua_pushboolean(L,false);
784 /******************************************************************************/
785 int ModApiMainMenu::l_extract_zip(lua_State *L)
787 GUIEngine* engine = getGuiEngine(L);
790 const char *zipfile = luaL_checkstring(L, 1);
791 const char *destination = luaL_checkstring(L, 2);
793 std::string absolute_destination = fs::RemoveRelativePathComponents(destination);
795 if (ModApiMainMenu::isMinetestPath(absolute_destination)) {
796 fs::CreateAllDirs(absolute_destination);
798 io::IFileSystem* fs = engine->m_device->getFileSystem();
800 fs->addFileArchive(zipfile,true,false,io::EFAT_ZIP);
802 assert(fs->getFileArchiveCount() > 0);
804 /**********************************************************************/
805 /* WARNING this is not threadsafe!! */
806 /**********************************************************************/
807 io::IFileArchive* opened_zip =
808 fs->getFileArchive(fs->getFileArchiveCount()-1);
810 const io::IFileList* files_in_zip = opened_zip->getFileList();
812 unsigned int number_of_files = files_in_zip->getFileCount();
814 for (unsigned int i=0; i < number_of_files; i++) {
815 std::string fullpath = destination;
816 fullpath += DIR_DELIM;
817 fullpath += files_in_zip->getFullFileName(i).c_str();
819 if (files_in_zip->isDirectory(i)) {
820 if (! fs::CreateAllDirs(fullpath) ) {
821 fs->removeFileArchive(fs->getFileArchiveCount()-1);
822 lua_pushboolean(L,false);
827 io::IReadFile* toread = opened_zip->createAndOpenFile(i);
829 FILE *targetfile = fopen(fullpath.c_str(),"wb");
831 if (targetfile == NULL) {
832 fs->removeFileArchive(fs->getFileArchiveCount()-1);
833 lua_pushboolean(L,false);
837 char read_buffer[1024];
838 unsigned int total_read = 0;
840 while (total_read < toread->getSize()) {
842 unsigned int bytes_read =
843 toread->read(read_buffer,sizeof(read_buffer));
844 unsigned int bytes_written;
845 if ((bytes_read < 0 ) ||
846 (bytes_written = fwrite(read_buffer, 1, bytes_read, targetfile) != bytes_read))
849 fs->removeFileArchive(fs->getFileArchiveCount()-1);
850 lua_pushboolean(L,false);
853 total_read += bytes_read;
861 fs->removeFileArchive(fs->getFileArchiveCount()-1);
862 lua_pushboolean(L,true);
866 lua_pushboolean(L,false);
870 /******************************************************************************/
871 int ModApiMainMenu::l_get_scriptdir(lua_State *L)
873 GUIEngine* engine = getGuiEngine(L);
876 lua_pushstring(L,engine->getScriptDir().c_str());
880 /******************************************************************************/
881 bool ModApiMainMenu::isMinetestPath(std::string path)
883 if (fs::PathStartsWith(path,fs::TempPath()))
887 if (fs::PathStartsWith(path,fs::RemoveRelativePathComponents(porting::path_share + DIR_DELIM + "games")))
891 if (fs::PathStartsWith(path,fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "mods")))
895 if (fs::PathStartsWith(path,fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "worlds")))
902 /******************************************************************************/
903 int ModApiMainMenu::l_show_file_open_dialog(lua_State *L)
905 GUIEngine* engine = getGuiEngine(L);
908 const char *formname= luaL_checkstring(L, 1);
909 const char *title = luaL_checkstring(L, 2);
911 GUIFileSelectMenu* fileOpenMenu =
912 new GUIFileSelectMenu(engine->m_device->getGUIEnvironment(),
915 engine->m_menumanager,
918 fileOpenMenu->setTextDest(engine->m_buttonhandler);
919 fileOpenMenu->drop();
923 /******************************************************************************/
924 int ModApiMainMenu::l_get_version(lua_State *L)
926 lua_pushstring(L,VERSION_STRING);
930 /******************************************************************************/
931 int ModApiMainMenu::l_sound_play(lua_State *L)
933 GUIEngine* engine = getGuiEngine(L);
935 SimpleSoundSpec spec;
936 read_soundspec(L, 1, spec);
937 bool looped = lua_toboolean(L, 2);
939 u32 handle = engine->playSound(spec, looped);
941 lua_pushinteger(L, handle);
946 /******************************************************************************/
947 int ModApiMainMenu::l_sound_stop(lua_State *L)
949 GUIEngine* engine = getGuiEngine(L);
951 u32 handle = luaL_checkinteger(L, 1);
952 engine->stopSound(handle);
957 /******************************************************************************/
958 int ModApiMainMenu::l_download_file(lua_State *L)
960 GUIEngine* engine = getGuiEngine(L);
963 const char *url = luaL_checkstring(L, 1);
964 const char *target = luaL_checkstring(L, 2);
967 std::string absolute_destination = fs::RemoveRelativePathComponents(target);
969 if (ModApiMainMenu::isMinetestPath(absolute_destination)) {
970 if (engine->downloadFile(url,absolute_destination)) {
971 lua_pushboolean(L,true);
975 lua_pushboolean(L,false);
979 /******************************************************************************/
980 int ModApiMainMenu::l_gettext(lua_State *L)
982 std::wstring wtext = wstrgettext((std::string) luaL_checkstring(L, 1));
983 lua_pushstring(L, wide_to_narrow(wtext).c_str());
988 /******************************************************************************/
989 void ModApiMainMenu::Initialize(lua_State *L, int top)
991 API_FCT(update_formspec);
993 API_FCT(get_textlist_index);
998 API_FCT(get_favorites);
999 API_FCT(show_keys_menu);
1000 API_FCT(create_world);
1001 API_FCT(delete_world);
1002 API_FCT(delete_favorite);
1003 API_FCT(set_background);
1004 API_FCT(set_topleft_text);
1005 API_FCT(get_modpath);
1006 API_FCT(get_gamepath);
1007 API_FCT(get_texturepath);
1008 API_FCT(get_dirlist);
1009 API_FCT(create_dir);
1010 API_FCT(delete_dir);
1012 API_FCT(extract_zip);
1013 API_FCT(get_scriptdir);
1014 API_FCT(show_file_open_dialog);
1015 API_FCT(get_version);
1016 API_FCT(download_file);
1017 API_FCT(get_modstore_details);
1018 API_FCT(get_modstore_list);
1019 API_FCT(sound_play);
1020 API_FCT(sound_stop);