mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2024-12-22 23:40:18 +01:00
improve skins sorting with same sort_id
add skins license hint to the README.md
This commit is contained in:
parent
a945db9de3
commit
166489597a
@ -39,6 +39,7 @@ You might want to run `minetest` in a Terminal/Console window to check the log o
|
||||
|
||||
## License:
|
||||
- GPLv3
|
||||
- skin texture licenses: See "meta" folder
|
||||
|
||||
### Credits
|
||||
|
||||
|
18
skinlist.lua
18
skinlist.lua
@ -69,6 +69,18 @@ for _, fn in pairs(skins_dir_list) do
|
||||
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
|
||||
function skins.get_skinlist(assignment, select_unassigned)
|
||||
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)
|
||||
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
|
||||
end
|
||||
|
||||
@ -92,7 +104,7 @@ function skins.get_skinlist_for_player(playername)
|
||||
table.insert(skinslist, skin)
|
||||
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
|
||||
end
|
||||
|
||||
@ -105,6 +117,6 @@ function skins.get_skinlist_with_meta(key, value)
|
||||
table.insert(skinslist, skin)
|
||||
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
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user