summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Weber <web.alexander@web.de>2017-06-15 13:45:42 +0200
committerAlexander Weber <web.alexander@web.de>2017-06-15 13:45:42 +0200
commit8713b09348db3075182696c856c2a390bd567e84 (patch)
treeff696ffbc617b6f411fbfe256a8caf8df9449835
parent2a195a77653dfccb49bb9b83b0b11ace1e5ff9db (diff)
updated reading skins list
-rw-r--r--skinlist.lua44
1 files changed, 23 insertions, 21 deletions
diff --git a/skinlist.lua b/skinlist.lua
index 91fa2e6..c42d7ea 100644
--- a/skinlist.lua
+++ b/skinlist.lua
@@ -1,26 +1,28 @@
skins.list = {}
skins.meta = {}
+skins.preview = {}
-local id = 1
-local internal_id = 1
-local fetched_skip = 0
-while fetched_skip < 40 do
- local name = "character_"..id
- 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[internal_id] = name
- 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??
-
- fetched_skip = 0
- internal_id = internal_id + 1
+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()
+ table.insert(skins.list, name)
+ 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
- fetched_skip = fetched_skip + 1
- id = id + 1
end
+