diff options
author | rubenwardy <rw@rubenwardy.com> | 2022-01-30 22:40:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-30 22:40:53 +0000 |
commit | 128f6359e936bcdc5e26409ddd73438bce9c6dd6 (patch) | |
tree | f4d396d479ae17f57f25ab78df300256e28d5945 /builtin/mainmenu/dlg_config_world.lua | |
parent | 8c0331d2449cf71049c7ce9c06d141e2846ebcb0 (diff) | |
download | minetest-128f6359e936bcdc5e26409ddd73438bce9c6dd6.tar.gz minetest-128f6359e936bcdc5e26409ddd73438bce9c6dd6.tar.bz2 minetest-128f6359e936bcdc5e26409ddd73438bce9c6dd6.zip |
Use virtual paths to specify exact mod to enable (#11784)
Diffstat (limited to 'builtin/mainmenu/dlg_config_world.lua')
-rw-r--r-- | builtin/mainmenu/dlg_config_world.lua | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index 9bdf92a74..510d9f804 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -205,14 +205,19 @@ local function handle_buttons(this, fields) local mods = worldfile:to_table() local rawlist = this.data.list:get_raw_list() + local was_set = {} for i = 1, #rawlist do local mod = rawlist[i] if not mod.is_modpack and not mod.is_game_content then if modname_valid(mod.name) then - worldfile:set("load_mod_" .. mod.name, - mod.enabled and "true" or "false") + if mod.enabled then + worldfile:set("load_mod_" .. mod.name, mod.virtual_path) + was_set[mod.name] = true + elseif not was_set[mod.name] then + worldfile:set("load_mod_" .. mod.name, "false") + end elseif mod.enabled then gamedata.errormessage = fgettext_ne("Failed to enable mo" .. "d \"$1\" as it contains disallowed characters. " .. @@ -256,12 +261,26 @@ local function handle_buttons(this, fields) if fields.btn_enable_all_mods then local list = this.data.list:get_raw_list() + -- When multiple copies of a mod are installed, we need to avoid enabling multiple of them + -- at a time. So lets first collect all the enabled mods, and then use this to exclude + -- multiple enables. + + local was_enabled = {} for i = 1, #list do if not list[i].is_game_content - and not list[i].is_modpack then + and not list[i].is_modpack and list[i].enabled then + was_enabled[list[i].name] = true + end + end + + for i = 1, #list do + if not list[i].is_game_content and not list[i].is_modpack and + not was_enabled[list[i].name] then list[i].enabled = true + was_enabled[list[i].name] = true end end + enabled_all = true return true end |