summaryrefslogtreecommitdiff
path: root/skinlist.lua
diff options
context:
space:
mode:
authorAlexander Weber <web.alexander@web.de>2017-06-18 23:15:58 +0200
committerAlexander Weber <web.alexander@web.de>2017-06-18 23:15:58 +0200
commit57b815f91ffd9bdd165c741350c6099f6b08685b (patch)
tree7070f5ff9fa564e68911defa017f328366f3d351 /skinlist.lua
parent920061c0f190d6e79bf6720c983bf1b24aba4bc7 (diff)
changes needed for character_creator support
Diffstat (limited to 'skinlist.lua')
-rw-r--r--skinlist.lua27
1 files changed, 9 insertions, 18 deletions
diff --git a/skinlist.lua b/skinlist.lua
index 328e518..e1be623 100644
--- a/skinlist.lua
+++ b/skinlist.lua
@@ -1,7 +1,6 @@
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
local nameparts = string.gsub(fn, "[.]", "_"):split("_")
@@ -43,28 +42,20 @@ for _, fn in pairs(skins_dir_list) do
else
skin_obj:set_meta("name", name)
end
- table.insert(unsorted_skinslist, skin_obj)
end
end
end
-- get skinlist. If assignment given ("mod:wardrobe" or "player:bell07") select skins matches the assignment. select_unassigned selects the skins without any assignment too
function skins.get_skinlist(assignment, select_unassigned)
- -- 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 assignment then
- return sorted_skinslist
- else
- local ret = {}
- for _, skin in ipairs(sorted_skinslist) do
- if assignment == skin:get_meta("assignment") or
- (select_unassigned and skin:get_meta("assignment") == nil) then
- table.insert(ret, skin)
- end
+ local skinslist = {}
+ for _, skin in pairs(skins.meta) do
+ if not assignment or
+ assignment == skin:get_meta("assignment") or
+ (select_unassigned and skin:get_meta("assignment") == nil) then
+ table.insert(skinslist, skin)
end
- return ret
end
+ table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
+ return skinslist
end