aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu/pkgmgr.lua
diff options
context:
space:
mode:
authoryou <ovvv@web.de>2018-05-29 18:37:51 +0200
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-05-29 18:37:51 +0200
commit7f7678e4e30fdae3722c3f75d4dc6488364d853e (patch)
tree9e7d4359101a4f53880d6b16e92396983db321be /builtin/mainmenu/pkgmgr.lua
parent75aa41c6de121f01d17cfb8f90916736496b2dce (diff)
downloadminetest-7f7678e4e30fdae3722c3f75d4dc6488364d853e.tar.gz
minetest-7f7678e4e30fdae3722c3f75d4dc6488364d853e.tar.bz2
minetest-7f7678e4e30fdae3722c3f75d4dc6488364d853e.zip
Tidy up dlg_config_world.lua (#5351)
Move code to pkgmgr
Diffstat (limited to 'builtin/mainmenu/pkgmgr.lua')
-rw-r--r--builtin/mainmenu/pkgmgr.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua
index 2730612e9..49ab78c24 100644
--- a/builtin/mainmenu/pkgmgr.lua
+++ b/builtin/mainmenu/pkgmgr.lua
@@ -309,6 +309,48 @@ function pkgmgr.get_dependencies(path)
return table.concat(info.depends or {}, ","), table.concat(info.optional_depends or {}, ",")
end
+----------- tests whether all of the mods in the modpack are enabled -----------
+function pkgmgr.is_modpack_entirely_enabled(data, name)
+ local rawlist = data.list:get_raw_list()
+ for j = 1, #rawlist do
+ if rawlist[j].modpack == name and not rawlist[j].enabled then
+ return false
+ end
+ end
+ return true
+end
+
+---------- toggles or en/disables a mod or modpack -----------------------------
+function pkgmgr.enable_mod(this, toset)
+ local mod = this.data.list:get_list()[this.data.selected_mod]
+
+ -- game mods can't be enabled or disabled
+ if mod.is_game_content then
+ return
+ end
+
+ -- toggle or en/disable the mod
+ if not mod.is_modpack then
+ if toset == nil then
+ mod.enabled = not mod.enabled
+ else
+ mod.enabled = toset
+ end
+ return
+ end
+
+ -- toggle or en/disable every mod in the modpack, interleaved unsupported
+ local list = this.data.list:get_raw_list()
+ for i = 1, #list do
+ if list[i].modpack == mod.name then
+ if toset == nil then
+ toset = not list[i].enabled
+ end
+ list[i].enabled = toset
+ end
+ end
+end
+
--------------------------------------------------------------------------------
function pkgmgr.get_worldconfig(worldpath)
local filename = worldpath ..