aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
Commit message (Expand)AuthorAge
...
* Fix some issues with animations, and allow non-looped animations to be definedMirceaKitsune2015-06-22
* Mapgen objects: Enable heatmap and humidmap for all biome api mapgensparamat2015-06-20
* Use utf-8 in formspecsIlya Zhuravlev2015-06-13
* Add return list of individual counts to find_node_in_areaTeTpaAka2015-06-13
* Make get_biome_list() error message more helpfulkwolekr2015-05-28
* Add some missing getter functions to the lua APITeTpaAka2015-05-28
* Replace instances of std::map<std::string, std::string> with StringMapkwolekr2015-05-19
* Fix null dereference when loading schematic from definition without a NodeDef...kwolekr2015-05-17
* Record MapBlock modification reasons as flags instead of stringskwolekr2015-05-17
* SAPI/Noise: Add PerlinNoiseMap:getMapSlice() functionkwolekr2015-05-17
* Add optional buffer param for bulk data array writes in Luakwolekr2015-05-17
* Fix current mod name change missed during rebaseShadowNinja2015-05-16
* SAPI: Accept either ARGB8 table or ColorString to specify colorskwolekr2015-05-16
* Add core.get_dir_listShadowNinja2015-05-16
* Add core.request_insecure_environment()ShadowNinja2015-05-16
* Add core.mkdirShadowNinja2015-05-16
* Add mod securityShadowNinja2015-05-16
* Add push_ARGB8 to script/common/c_converterTeTpaAka2015-05-15
* Generalize core.get/set_nametag_color into core.get/set_nametag_attributesTeTpaAka2015-05-15
* Add get and set functions for the nametag colorTeTpaAka2015-05-15
* Fix compiler warning about sign comparisonest312015-05-13
* is_player() is no player-only functionest312015-05-12
* Make early protocol auth mechanism generic, and add SRPest312015-05-11
* Schematics: Add per-node force placement optionkwolekr2015-05-09
* Tests: Add schematic unittestskwolekr2015-05-08
* Schematics: Add indent-with-space option for schematic Lua table serializationkwolekr2015-05-07
* NodeResolver: Remove NodeResolveMethodkwolekr2015-05-07
* Add core.find_nodes_with_meta() script APIkwolekr2015-05-05
* Ore: Add biomes parameterkwolekr2015-04-20
* Add 'persistence' alias for Lua noiseparams and validate more vector parameterskwolekr2015-04-19
* Biome API: Add biome-specific river waterparamat2015-04-19
* Schematics: Fix core.schematic_create()kwolekr2015-04-17
* Switch to check_v3s16 in l_mapgen.cpp and l_vmanip.cpp for type safetykwolekr2015-04-17
* Refactor around translatePasswordest312015-04-17
* Biomes: Remove referenced biomes from Decorations on clearkwolekr2015-04-16
* Schematics: Refactor NodeResolver and add NodeResolveMethodkwolekr2015-04-16
* Use std::vector instead of std::set for Environment::getObjectsInsideRadiusLoic Blot2015-04-16
* Schematics: Reorganize (de)serialization and add Lua serialization APIkwolekr2015-04-13
* Document for api functions that rely on current_modname, that it doesn't work...est312015-04-08
* Schematics: Prepend mod path to relative schematic filepathskwolekr2015-04-08
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
* ObjDefManager, Mapgen SAPI: Huge refactoringkwolekr2015-03-31
* GenElementManager: Pass opaque handles to Lua and rename to ObjDefManagerkwolekr2015-03-31
* Fix typoCraig Robbins2015-03-29
* Add Lua function get_video_modes() for main menuCraig Robbins2015-03-28
* Clean up and tweak build systemShadowNinja2015-03-27
* lua_api/l_mapgen: generate_ores/decorations: make p1, p2 optionalparamat2015-03-24
* Add core.register_schematic() and cache schematics on usekwolekr2015-03-23
* Fix minetest.get_craft_recipe functionest312015-03-23
* Revert "Add a Lua call to do damages / heals" ok @ShadowNinjaLoic Blot2015-03-22
an class="hl kwc">std::vector<GameFindPath> find_paths; find_paths.push_back(GameFindPath( user + DIR_DELIM + "games" + DIR_DELIM + id + "_game", true)); find_paths.push_back(GameFindPath( user + DIR_DELIM + "games" + DIR_DELIM + id, true)); find_paths.push_back(GameFindPath( share + DIR_DELIM + "games" + DIR_DELIM + id + "_game", false)); find_paths.push_back(GameFindPath( share + DIR_DELIM + "games" + DIR_DELIM + id, false)); // Find game directory std::string game_path; bool user_game = true; // Game is in user's directory for(u32 i=0; i<find_paths.size(); i++){ const std::string &try_path = find_paths[i].path; if(fs::PathExists(try_path)){ game_path = try_path; user_game = find_paths[i].user_specific; break; } } if(game_path == "") return SubgameSpec(); std::string gamemod_path = game_path + DIR_DELIM + "mods"; // Find mod directories std::set<std::string> mods_paths; if(!user_game) mods_paths.insert(share + DIR_DELIM + "mods" + DIR_DELIM + id); if(user != share || user_game) mods_paths.insert(user + DIR_DELIM + "mods" + DIR_DELIM + id); std::string game_name = getGameName(game_path); if(game_name == "") game_name = id; std::string menuicon_path; #ifndef SERVER menuicon_path = getImagePath(game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png"); #endif return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name, menuicon_path); } SubgameSpec findWorldSubgame(const std::string &world_path) { std::string world_gameid = getWorldGameId(world_path, true); // See if world contains an embedded game; if so, use it. std::string world_gamepath = world_path + DIR_DELIM + "game"; if(fs::PathExists(world_gamepath)){ SubgameSpec gamespec; gamespec.id = world_gameid; gamespec.path = world_gamepath; gamespec.gamemods_path= world_gamepath + DIR_DELIM + "mods"; gamespec.name = getGameName(world_gamepath); if(gamespec.name == "") gamespec.name = "unknown"; return gamespec; } return findSubgame(world_gameid); } std::set<std::string> getAvailableGameIds() { std::set<std::string> gameids; std::set<std::string> gamespaths; gamespaths.insert(porting::path_share + DIR_DELIM + "games"); gamespaths.insert(porting::path_user + DIR_DELIM + "games"); for(std::set<std::string>::const_iterator i = gamespaths.begin(); i != gamespaths.end(); i++){ std::vector<fs::DirListNode> dirlist = fs::GetDirListing(*i); for(u32 j=0; j<dirlist.size(); j++){ if(!dirlist[j].dir) continue; // If configuration file is not found or broken, ignore game Settings conf; if(!getGameConfig(*i + DIR_DELIM + dirlist[j].name, conf)) continue; // Add it to result const char *ends[] = {"_game", NULL}; std::string shorter = removeStringEnd(dirlist[j].name, ends); if(shorter != "") gameids.insert(shorter); else gameids.insert(dirlist[j].name); } } return gameids; } std::vector<SubgameSpec> getAvailableGames() { std::vector<SubgameSpec> specs; std::set<std::string> gameids = getAvailableGameIds(); for(std::set<std::string>::const_iterator i = gameids.begin(); i != gameids.end(); i++) specs.push_back(findSubgame(*i)); return specs; } #define LEGACY_GAMEID "minetest" bool getWorldExists(const std::string &world_path) { return (fs::PathExists(world_path + DIR_DELIM + "map_meta.txt") || fs::PathExists(world_path + DIR_DELIM + "world.mt")); } std::string getWorldGameId(const std::string &world_path, bool can_be_legacy) { std::string conf_path = world_path + DIR_DELIM + "world.mt"; Settings conf; bool succeeded = conf.readConfigFile(conf_path.c_str()); if(!succeeded){ if(can_be_legacy){ // If map_meta.txt exists, it is probably an old minetest world if(fs::PathExists(world_path + DIR_DELIM + "map_meta.txt")) return LEGACY_GAMEID; } return ""; } if(!conf.exists("gameid")) return ""; // The "mesetint" gameid has been discarded if(conf.get("gameid") == "mesetint") return "minetest"; return conf.get("gameid"); } std::vector<WorldSpec> getAvailableWorlds() { std::vector<WorldSpec> worlds; std::set<std::string> worldspaths; worldspaths.insert(porting::path_user + DIR_DELIM + "worlds"); infostream<<"Searching worlds..."<<std::endl; for(std::set<std::string>::const_iterator i = worldspaths.begin(); i != worldspaths.end(); i++){ infostream<<" In "<<(*i)<<": "<<std::endl; std::vector<fs::DirListNode> dirvector = fs::GetDirListing(*i); for(u32 j=0; j<dirvector.size(); j++){ if(!dirvector[j].dir) continue; std::string fullpath = *i + DIR_DELIM + dirvector[j].name; std::string name = dirvector[j].name; // Just allow filling in the gameid always for now bool can_be_legacy = true; std::string gameid = getWorldGameId(fullpath, can_be_legacy); WorldSpec spec(fullpath, name, gameid); if(!spec.isValid()){ infostream<<"(invalid: "<<name<<") "; } else { infostream<<name<<" "; worlds.push_back(spec); } } infostream<<std::endl; } // Check old world location do{ std::string fullpath = porting::path_user + DIR_DELIM + "world"; if(!fs::PathExists(fullpath)) break; std::string name = "Old World"; std::string gameid = getWorldGameId(fullpath, true); WorldSpec spec(fullpath, name, gameid); infostream<<"Old world found."<<std::endl; worlds.push_back(spec); }while(0); infostream<<worlds.size()<<" found."<<std::endl; return worlds; } bool initializeWorld(const std::string &path, const std::string &gameid) { infostream<<"Initializing world at "<<path<<std::endl; // Create world.mt if does not already exist std::string worldmt_path = path + DIR_DELIM + "world.mt"; if(!fs::PathExists(worldmt_path)){ infostream<<"Creating world.mt ("<<worldmt_path<<")"<<std::endl; fs::CreateAllDirs(path); std::ofstream of(worldmt_path.c_str(), std::ios::binary); of<<"gameid = "<<gameid<<"\n"; } return true; }