Add skins.get_skinlist_with_meta(key, value) and small adjustments

This commit is contained in:
Alexander Weber
2018-01-07 19:09:52 +01:00
parent 7df6363aa0
commit 429874698e
3 changed files with 24 additions and 7 deletions

View File

@ -82,3 +82,16 @@ function skins.get_skinlist_for_player(playername)
table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
return skinslist
end
-- Get skinlist selected by metadata
function skins.get_skinlist_with_meta(key, value)
assert(key, "key parameter for skins.get_skinlist_with_meta() missed")
local skinslist = {}
for _, skin in pairs(skins.meta) do
if skin:get_meta(key) == value then
table.insert(skinslist, skin)
end
end
table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
return skinslist
end