diff options
author | Alexander Weber <web.alexander@web.de> | 2017-06-17 00:23:39 +0200 |
---|---|---|
committer | Alexander Weber <web.alexander@web.de> | 2017-06-17 00:23:39 +0200 |
commit | 50e6c9e2d01bbeb04be7fcaf58ff5233125b3ff3 (patch) | |
tree | 10af912f96ceccfed7b8b4b33ccd052b2edb4cd1 /skinlist.lua | |
parent | 077312257de7f3fa5c3b815e5b81b001a26d9f9d (diff) |
added skins.get_skinlist(listname), sfinv prepared for per player skinlist
Diffstat (limited to 'skinlist.lua')
-rw-r--r-- | skinlist.lua | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/skinlist.lua b/skinlist.lua index 5b074fd..87fe3f6 100644 --- a/skinlist.lua +++ b/skinlist.lua @@ -1,7 +1,7 @@ -skins.list = {} local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures") local unsorted_skinslist = {} +local sorted_skinslist for _, fn in pairs(skins_dir_list) do if fn:find("^character_") then nameparts = string.gsub(fn, "[.]", "_"):split("_") @@ -26,7 +26,22 @@ for _, fn in pairs(skins_dir_list) do end end -table.sort(unsorted_skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end) -for _,v in ipairs(unsorted_skinslist) do - table.insert(skins.list, v) +-- get skinlist. listname not full implemented at the time: could be "mod:wardrobe" or "player:bell07" in feature +function skins.get_skinlist(listname) + -- sort on demand + if not sorted_skinslist then + table.sort(unsorted_skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end) + sorted_skinslist = unsorted_skinslist + end + if not listname then + return sorted_skinslist + else + local ret = {} + for _, skin in ipairs(sorted_skinslist) do + if skin:get_meta(listname) then + table.insert(ret, skin) + end + end + return ret + end end |