diff options
author | Alexander Weber <web.alexander@web.de> | 2017-06-16 23:00:36 +0200 |
---|---|---|
committer | Alexander Weber <web.alexander@web.de> | 2017-06-16 23:00:36 +0200 |
commit | 28d28390ce5d67f47db184cbbbc4ecd74be77eb2 (patch) | |
tree | 2dde0e088559a878d6006fa3f3779b5ac3adb1b0 /skinlist.lua | |
parent | b267cf26579623565f5a85bee9e8584a5467a85f (diff) |
started work on skin_meta_api
Diffstat (limited to 'skinlist.lua')
-rw-r--r-- | skinlist.lua | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/skinlist.lua b/skinlist.lua index e050497..da59a47 100644 --- a/skinlist.lua +++ b/skinlist.lua @@ -1,7 +1,4 @@ skins.list = {} -skins.textures = {} -skins.meta = {} -skins.preview = {} local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures") local unsorted_skinslist = {} @@ -10,26 +7,25 @@ for _, fn in pairs(skins_dir_list) do nameparts = string.gsub(fn, "[.]", "_"):split("_") local id = nameparts[2] local name = "character_"..id + local skin_obj = skins.get(name) or skins.new(new) if nameparts[3] == "preview" then - skins.preview[name] = fn + skin_obj:set_preview(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() - table.insert(unsorted_skinslist, {id = tonumber(id) or id, name = name}) - skins.textures[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?? + 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]) end end end end -table.sort(unsorted_skinslist, function(a,b) return a.id < b.id end) +table.sort(unsorted_skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end) for _,v in ipairs(unsorted_skinslist) do - table.insert(skins.list, v.name) + table.insert(skins.list, v) end |