improve skins sorting with same sort_id

add skins license hint to the README.md
This commit is contained in:
Alexander Weber 2019-08-09 06:54:47 +02:00
parent a945db9de3
commit 166489597a
2 changed files with 16 additions and 3 deletions

View File

@ -39,6 +39,7 @@ You might want to run `minetest` in a Terminal/Console window to check the log o
## License: ## License:
- GPLv3 - GPLv3
- skin texture licenses: See "meta" folder
### Credits ### Credits

View File

@ -69,6 +69,18 @@ for _, fn in pairs(skins_dir_list) do
end end
end end
local function skins_sort(skinslist)
table.sort(skinslist, function(a,b)
local a_id = a:get_meta("_sort_id")
local b_id = b:get_meta("_sort_id")
if a_id ~= b_id then
return a:get_meta("_sort_id") < b:get_meta("_sort_id")
else
return a:get_meta("name") < b:get_meta("name")
end
end)
end
-- (obsolete) get skinlist. If assignment given ("mod:wardrobe" or "player:bell07") select skins matches the assignment. select_unassigned selects the skins without any assignment too -- (obsolete) 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) function skins.get_skinlist(assignment, select_unassigned)
minetest.log("deprecated", "skins.get_skinlist() is deprecated. Use skins.get_skinlist_for_player() instead") minetest.log("deprecated", "skins.get_skinlist() is deprecated. Use skins.get_skinlist_for_player() instead")
@ -80,7 +92,7 @@ function skins.get_skinlist(assignment, select_unassigned)
table.insert(skinslist, skin) table.insert(skinslist, skin)
end end
end end
table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end) skins_sort(skinslist)
return skinslist return skinslist
end end
@ -92,7 +104,7 @@ function skins.get_skinlist_for_player(playername)
table.insert(skinslist, skin) table.insert(skinslist, skin)
end end
end end
table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end) skins_sort(skinslist)
return skinslist return skinslist
end end
@ -105,6 +117,6 @@ function skins.get_skinlist_with_meta(key, value)
table.insert(skinslist, skin) table.insert(skinslist, skin)
end end
end end
table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end) skins_sort(skinslist)
return skinslist return skinslist
end end