2017-02-09 23:06:25 +01:00
|
|
|
skins.list = {}
|
2017-06-15 16:16:57 +02:00
|
|
|
skins.textures = {}
|
2017-02-09 23:06:25 +01:00
|
|
|
skins.meta = {}
|
2017-06-15 13:45:42 +02:00
|
|
|
skins.preview = {}
|
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
|
|
|
|
if nameparts[3] == "preview" then
|
|
|
|
skins.preview[name] = fn
|
|
|
|
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-15 16:16:57 +02:00
|
|
|
table.insert(unsorted_skinslist, {id = tonumber(id) or id, name = name})
|
|
|
|
skins.textures[name] = fn
|
2017-06-15 13:45:42 +02:00
|
|
|
skins.meta[name] = {}
|
|
|
|
skins.meta[name].name = data[1]
|
|
|
|
skins.meta[name].author = data[2]
|
|
|
|
skins.meta[name].license = data[3]
|
|
|
|
skins.meta[name].description = "" --what's that??
|
|
|
|
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-15 16:16:57 +02:00
|
|
|
table.sort(unsorted_skinslist, function(a,b) return a.id < b.id end)
|
|
|
|
for _,v in ipairs(unsorted_skinslist) do
|
|
|
|
table.insert(skins.list, v.name)
|
|
|
|
end
|