summaryrefslogtreecommitdiff
path: root/skinlist.lua
diff options
context:
space:
mode:
authorAlexander Weber <web.alexander@web.de>2018-01-07 19:09:52 +0100
committerAlexander Weber <web.alexander@web.de>2018-01-07 19:09:52 +0100
commit429874698ea5176e15a3b5703ac734b5b123d842 (patch)
tree560d03e39bae1038f6f483bec00546c36ffbaf06 /skinlist.lua
parent7df6363aa0247068205a09815721164813849b19 (diff)
Add skins.get_skinlist_with_meta(key, value) and small adjustments
Diffstat (limited to 'skinlist.lua')
-rw-r--r--skinlist.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/skinlist.lua b/skinlist.lua
index 889b531..0a06f5d 100644
--- a/skinlist.lua
+++ b/skinlist.lua
@@ -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