mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 11:33:44 +01:00
parent
f3b7be97fe
commit
9f19b7d936
@ -594,32 +594,19 @@ int ModApiMainMenu::l_create_world(lua_State *L)
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_delete_world(lua_State *L)
|
||||
{
|
||||
int worldidx = luaL_checkinteger(L,1) -1;
|
||||
|
||||
int world_id = luaL_checkinteger(L, 1) - 1;
|
||||
std::vector<WorldSpec> worlds = getAvailableWorlds();
|
||||
|
||||
if ((worldidx >= 0) &&
|
||||
(worldidx < (int) worlds.size())) {
|
||||
|
||||
WorldSpec spec = worlds[worldidx];
|
||||
|
||||
std::vector<std::string> paths;
|
||||
paths.push_back(spec.path);
|
||||
fs::GetRecursiveSubPaths(spec.path, paths, true);
|
||||
|
||||
// Delete files
|
||||
if (!fs::DeletePaths(paths)) {
|
||||
lua_pushstring(L, "Failed to delete world");
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (world_id < 0 || world_id >= (int) worlds.size()) {
|
||||
lua_pushstring(L, "Invalid world index");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
const WorldSpec &spec = worlds[world_id];
|
||||
if (!fs::RecursiveDelete(spec.path)) {
|
||||
lua_pushstring(L, "Failed to delete world");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_set_topleft_text(lua_State *L)
|
||||
|
Loading…
Reference in New Issue
Block a user