summaryrefslogtreecommitdiff
path: root/skinlist.lua
blob: b38246f8e7295abe6ef57077300cd42e00d0787b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
skins.list = {}
skins.meta = {}
skins.preview = {}

local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures")
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()
				skins.list[name] = fn
				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
	end
end