2017-02-09 23:06:25 +01:00
|
|
|
skins.list = {}
|
2014-03-17 06:26:58 +01:00
|
|
|
|
2017-06-15 13:45:42 +02:00
|
|
|
local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures")
|
2017-06-15 16:16:57 +02:00
|
|
|
local unsorted_skinslist = {}
|
2017-06-15 13:45:42 +02:00
|
|
|
for _, fn in pairs(skins_dir_list) do
|
|
|
|
if fn:find("^character_") then
|
|
|
|
nameparts = string.gsub(fn, "[.]", "_"):split("_")
|
|
|
|
local id = nameparts[2]
|
|
|
|
local name = "character_"..id
|
2017-06-16 23:00:36 +02:00
|
|
|
local skin_obj = skins.get(name) or skins.new(new)
|
2017-06-15 13:45:42 +02:00
|
|
|
if nameparts[3] == "preview" then
|
2017-06-16 23:00:36 +02:00
|
|
|
skin_obj:set_preview(fn)
|
2017-06-15 13:45:42 +02:00
|
|
|
else
|
|
|
|
local file = io.open(skins.modpath.."/meta/"..name..".txt", "r")
|
|
|
|
if file then
|
|
|
|
local data = string.split(file:read("*all"), "\n", 3)
|
|
|
|
file:close()
|
2017-06-16 23:00:36 +02:00
|
|
|
skin_obj:set_texture(fn)
|
|
|
|
skin_obj:set_meta("_sort_id", tonumber(id))
|
|
|
|
skin_obj:set_meta("name", data[1])
|
|
|
|
skin_obj:set_meta("author", data[2])
|
|
|
|
skin_obj:set_meta("license", data[3])
|
2017-06-15 13:45:42 +02:00
|
|
|
end
|
|
|
|
end
|
2014-07-23 13:46:42 +02:00
|
|
|
end
|
2017-02-09 23:06:25 +01:00
|
|
|
end
|
2017-06-15 13:45:42 +02:00
|
|
|
|
2017-06-16 23:00:36 +02:00
|
|
|
table.sort(unsorted_skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
|
2017-06-15 16:16:57 +02:00
|
|
|
for _,v in ipairs(unsorted_skinslist) do
|
2017-06-16 23:00:36 +02:00
|
|
|
table.insert(skins.list, v)
|
2017-06-15 16:16:57 +02:00
|
|
|
end
|