|
19 | 19 | function get_mods(path,retval,modpack)
|
20 | 20 | local mods = core.get_dir_list(path, true)
|
21 | 21 |
|
22 |
| - for i=1, #mods, 1 do |
23 |
| - if mods[i]:sub(1,1) ~= "." then |
| 22 | + for _, name in ipairs(mods) do |
| 23 | + if name:sub(1, 1) ~= "." then |
| 24 | + local prefix = path .. DIR_DELIM .. name .. DIR_DELIM |
24 | 25 | local toadd = {}
|
25 |
| - local modpackfile = nil |
| 26 | + table.insert(retval, toadd) |
26 | 27 |
|
27 |
| - toadd.name = mods[i] |
28 |
| - toadd.path = path .. DIR_DELIM .. mods[i] .. DIR_DELIM |
29 |
| - if modpack ~= nil and |
30 |
| - modpack ~= "" then |
31 |
| - toadd.modpack = modpack |
32 |
| - else |
33 |
| - local filename = path .. DIR_DELIM .. mods[i] .. DIR_DELIM .. "modpack.txt" |
34 |
| - local error = nil |
35 |
| - modpackfile,error = io.open(filename,"r") |
| 28 | + local mod_conf = Settings(prefix .. "mod.conf"):to_table() |
| 29 | + if mod_conf.name then |
| 30 | + name = mod_conf.name |
36 | 31 | end
|
37 | 32 |
|
38 |
| - if modpackfile ~= nil then |
39 |
| - modpackfile:close() |
40 |
| - toadd.is_modpack = true |
41 |
| - table.insert(retval,toadd) |
42 |
| - get_mods(path .. DIR_DELIM .. mods[i],retval,mods[i]) |
| 33 | + toadd.name = name |
| 34 | + toadd.path = prefix |
| 35 | + |
| 36 | + if modpack ~= nil and modpack ~= "" then |
| 37 | + toadd.modpack = modpack |
43 | 38 | else
|
44 |
| - table.insert(retval,toadd) |
| 39 | + local modpackfile = io.open(prefix .. "modpack.txt") |
| 40 | + if modpackfile then |
| 41 | + modpackfile:close() |
| 42 | + toadd.is_modpack = true |
| 43 | + get_mods(prefix, retval, name) |
| 44 | + end |
45 | 45 | end
|
46 | 46 | end
|
47 | 47 | end
|
|
0 commit comments