mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Change mg_flags for lua defiend mapgens
This commit is contained in:
parent
0275ab9f73
commit
63282704dc
4 changed files with 68 additions and 36 deletions
|
@ -183,9 +183,9 @@ local function create_world_formspec(dialogdata)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local allowed_lua_mapgen_settings = {}
|
local lua_mapgen_allowed_mg_flags = {}
|
||||||
if is_lua_mapgen and lua_mapgens[current_mapgen].mapgen_flags then
|
if is_lua_mapgen and lua_mapgens[current_mapgen].mg_flags then
|
||||||
allowed_lua_mapgen_settings = lua_mapgens[current_mapgen].mapgen_flags
|
lua_mapgen_allowed_mg_flags = lua_mapgens[current_mapgen].mg_flags
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The logic of the flag element IDs is as follows:
|
-- The logic of the flag element IDs is as follows:
|
||||||
|
@ -199,36 +199,68 @@ local function create_world_formspec(dialogdata)
|
||||||
if disallowed_mapgen_settings["mg_flags"] then
|
if disallowed_mapgen_settings["mg_flags"] then
|
||||||
return "", y
|
return "", y
|
||||||
end
|
end
|
||||||
if is_lua_mapgen and not allowed_lua_mapgen_settings["mg_flags"] then
|
if is_lua_mapgen and lua_mapgen_allowed_mg_flags == {} then
|
||||||
return "", y
|
return "", y
|
||||||
end
|
end
|
||||||
|
|
||||||
local form = "checkbox[0," .. y .. ";flag_main_caves;" ..
|
local form = ""
|
||||||
fgettext("Caves") .. ";"..strflag(flags.main, "caves").."]"
|
|
||||||
y = y + 0.5
|
|
||||||
|
|
||||||
form = form .. "checkbox[0,"..y..";flag_main_dungeons;" ..
|
if not is_lua_mapgen or lua_mapgen_allowed_mg_flags["caves"] then
|
||||||
fgettext("Dungeons") .. ";"..strflag(flags.main, "dungeons").."]"
|
form = form .. "checkbox[0," .. y .. ";flag_main_caves;" ..
|
||||||
y = y + 0.5
|
fgettext("Caves") .. ";"..strflag(flags.main, "caves").."]"
|
||||||
|
y = y + 0.5
|
||||||
local d_name = fgettext("Decorations")
|
|
||||||
local d_tt
|
|
||||||
if mapgen == "v6" then
|
|
||||||
d_tt = fgettext("Structures appearing on the terrain (no effect on trees and jungle grass created by v6)")
|
|
||||||
else
|
|
||||||
d_tt = fgettext("Structures appearing on the terrain, typically trees and plants")
|
|
||||||
end
|
end
|
||||||
form = form .. "checkbox[0,"..y..";flag_main_decorations;" ..
|
|
||||||
d_name .. ";" ..
|
|
||||||
strflag(flags.main, "decorations").."]" ..
|
|
||||||
"tooltip[flag_mg_decorations;" ..
|
|
||||||
d_tt ..
|
|
||||||
"]"
|
|
||||||
y = y + 0.5
|
|
||||||
|
|
||||||
form = form .. "tooltip[flag_main_caves;" ..
|
if not is_lua_mapgen or lua_mapgen_allowed_mg_flags["dungeons"] then
|
||||||
fgettext("Network of tunnels and caves")
|
form = form .. "checkbox[0,"..y..";flag_main_dungeons;" ..
|
||||||
.. "]"
|
fgettext("Dungeons") .. ";"..strflag(flags.main, "dungeons").."]"
|
||||||
|
y = y + 0.5
|
||||||
|
end
|
||||||
|
|
||||||
|
if not is_lua_mapgen or lua_mapgen_allowed_mg_flags["decorations"] then
|
||||||
|
local d_name = fgettext("Decorations")
|
||||||
|
local d_tt
|
||||||
|
if mapgen == "v6" then
|
||||||
|
d_tt = fgettext("Structures appearing on the terrain (no effect on trees and jungle grass created by v6)")
|
||||||
|
else
|
||||||
|
d_tt = fgettext("Structures appearing on the terrain, typically trees and plants")
|
||||||
|
end
|
||||||
|
form = form .. "checkbox[0,"..y..";flag_main_decorations;" ..
|
||||||
|
d_name .. ";" ..
|
||||||
|
strflag(flags.main, "decorations").."]" ..
|
||||||
|
"tooltip[flag_mg_decorations;" ..
|
||||||
|
d_tt ..
|
||||||
|
"]"
|
||||||
|
y = y + 0.5
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Allow all to be shown for Lua mapgens
|
||||||
|
if is_lua_mapgen then
|
||||||
|
if lua_mapgen_allowed_mg_flags["ores"] then
|
||||||
|
form = form .. "checkbox[0,"..y..";flag_main_ores;" ..
|
||||||
|
fgettext("Ores") .. ";"..strflag(flags.main, "ores").."]"
|
||||||
|
y = y + 0.5
|
||||||
|
end
|
||||||
|
if lua_mapgen_allowed_mg_flags["biomes"] then
|
||||||
|
form = form .. "checkbox[0,"..y..";flag_main_biomes;" ..
|
||||||
|
fgettext("Biomes") .. ";"..strflag(flags.main, "biomes").."]"
|
||||||
|
y = y + 0.5
|
||||||
|
end
|
||||||
|
if lua_mapgen_allowed_mg_flags["light"] then
|
||||||
|
form = form .. "checkbox[0,"..y..";flag_main_light;" ..
|
||||||
|
fgettext("Light") .. ";"..strflag(flags.main, "light").."]" ..
|
||||||
|
"tooltip[flag_main_light;" ..
|
||||||
|
fgettext("This is not recommended, as it will disable engine lighting.") ..
|
||||||
|
"]"
|
||||||
|
y = y + 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if form ~= "" then
|
||||||
|
form = form .. "tooltip[flag_main_caves;" ..
|
||||||
|
fgettext("Network of tunnels and caves")
|
||||||
|
.. "]"
|
||||||
|
end
|
||||||
return form, y
|
return form, y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -147,12 +147,12 @@ bool parseModContents(ModSpec &spec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (info.exists("mapgen_flags")) {
|
if (info.exists("mg_flags")) {
|
||||||
std::string dep = info.get("mapgen_flags");
|
std::string dep = info.get("mg_flags");
|
||||||
dep.erase(std::remove_if(dep.begin(), dep.end(),
|
dep.erase(std::remove_if(dep.begin(), dep.end(),
|
||||||
static_cast<int (*)(int)>(&std::isspace)), dep.end());
|
static_cast<int (*)(int)>(&std::isspace)), dep.end());
|
||||||
for (const auto &flag : str_split(dep, ',')) {
|
for (const auto &flag : str_split(dep, ',')) {
|
||||||
spec.mapgen_flags.insert(flag);
|
spec.mg_flags.insert(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct ModSpec
|
||||||
|
|
||||||
// lua-defined mapgen only
|
// lua-defined mapgen only
|
||||||
bool is_mapgen = false;
|
bool is_mapgen = false;
|
||||||
std::unordered_set<std::string> mapgen_flags;
|
std::unordered_set<std::string> mg_flags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A constructed canonical path to represent this mod's location.
|
* A constructed canonical path to represent this mod's location.
|
||||||
|
|
|
@ -704,14 +704,14 @@ int ModApiMainMenu::l_get_lua_mapgens(lua_State *L)
|
||||||
}
|
}
|
||||||
lua_settable(L, top_lvl2);
|
lua_settable(L, top_lvl2);
|
||||||
|
|
||||||
lua_pushstring(L, "mapgen_flags");
|
lua_pushstring(L, "mg_flags");
|
||||||
if (!mod.mapgen_flags.empty()) {
|
if (!mod.mg_flags.empty()) {
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
int mapgen_flags_top = lua_gettop(L);
|
int mg_flags_top = lua_gettop(L);
|
||||||
for (const auto &flag : mod.mapgen_flags) {
|
for (const auto &flag : mod.mg_flags) {
|
||||||
lua_pushstring(L, flag.c_str());
|
lua_pushstring(L, flag.c_str());
|
||||||
lua_pushboolean(L, true);
|
lua_pushboolean(L, true);
|
||||||
lua_settable(L, mapgen_flags_top);
|
lua_settable(L, mg_flags_top);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue