summaryrefslogtreecommitdiff
path: root/builtin/mainmenu/pkgmgr.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/mainmenu/pkgmgr.lua')
-rw-r--r--builtin/mainmenu/pkgmgr.lua74
1 files changed, 65 insertions, 9 deletions
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua
index f87367689..5b8807310 100644
--- a/builtin/mainmenu/pkgmgr.lua
+++ b/builtin/mainmenu/pkgmgr.lua
@@ -16,6 +16,62 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------------
+local function get_last_folder(text,count)
+ local parts = text:split(DIR_DELIM)
+
+ if count == nil then
+ return parts[#parts]
+ end
+
+ local retval = ""
+ for i=1,count,1 do
+ retval = retval .. parts[#parts - (count-i)] .. DIR_DELIM
+ end
+
+ return retval
+end
+
+local function cleanup_path(temppath)
+
+ local parts = temppath:split("-")
+ temppath = ""
+ for i=1,#parts,1 do
+ if temppath ~= "" then
+ temppath = temppath .. "_"
+ end
+ temppath = temppath .. parts[i]
+ end
+
+ parts = temppath:split(".")
+ temppath = ""
+ for i=1,#parts,1 do
+ if temppath ~= "" then
+ temppath = temppath .. "_"
+ end
+ temppath = temppath .. parts[i]
+ end
+
+ parts = temppath:split("'")
+ temppath = ""
+ for i=1,#parts,1 do
+ if temppath ~= "" then
+ temppath = temppath .. ""
+ end
+ temppath = temppath .. parts[i]
+ end
+
+ parts = temppath:split(" ")
+ temppath = ""
+ for i=1,#parts,1 do
+ if temppath ~= "" then
+ temppath = temppath
+ end
+ temppath = temppath .. parts[i]
+ end
+
+ return temppath
+end
+
function get_mods(path,retval,modpack)
local mods = core.get_dir_list(path, true)
@@ -403,9 +459,9 @@ function pkgmgr.enable_mod(this, toset)
-- Make a list of mod ids indexed by their names
local mod_ids = {}
- for id, mod in pairs(list) do
- if mod.type == "mod" and not mod.is_modpack then
- mod_ids[mod.name] = id
+ for id, mod2 in pairs(list) do
+ if mod2.type == "mod" and not mod2.is_modpack then
+ mod_ids[mod2.name] = id
end
end
@@ -429,17 +485,17 @@ function pkgmgr.enable_mod(this, toset)
if not enabled_mods[name] then
enabled_mods[name] = true
- local mod = list[mod_ids[name]]
- if not mod then
+ local mod_to_enable = list[mod_ids[name]]
+ if not mod_to_enable then
minetest.log("warning", "Mod dependency \"" .. name ..
"\" not found!")
else
- if mod.enabled == false then
- mod.enabled = true
- toggled_mods[#toggled_mods+1] = mod.name
+ if mod_to_enable.enabled == false then
+ mod_to_enable.enabled = true
+ toggled_mods[#toggled_mods+1] = mod_to_enable.name
end
-- Push the dependencies of the dependency onto the stack
- local depends = pkgmgr.get_dependencies(mod.path)
+ local depends = pkgmgr.get_dependencies(mod_to_enable.path)
for i = 1, #depends do
if not enabled_mods[name] then
sp = sp+1