1
0
Fork 0
VoxeLibre/mods/PLAYER/mcl_skins/simple_skins.lua

48 lines
982 B
Lua
Raw Permalink Normal View History

2022-09-06 19:51:43 +02:00
local function init_simple_skins()
2023-04-27 05:01:37 +02:00
local id, f, data, skin = 2
2022-09-06 19:51:43 +02:00
local mod_path = minetest.get_modpath("mcl_skins")
while true do
if id == 0 then
skin = "character.png"
else
skin = "mcl_skins_character_" .. id .. ".png"
-- Does skin file exist?
f = io.open(mod_path .. "/textures/" .. skin)
-- escape loop if not found
if not f then
break
end
f:close()
end
local metafile
-- does metadata exist for that skin file ?
if id == 0 then
metafile = "mcl_skins_character.txt"
else
metafile = "mcl_skins_character_"..id..".txt"
end
f = io.open(mod_path .. "/meta/" .. metafile)
data = nil
if f then
data = minetest.deserialize("return {" .. f:read("*all") .. "}")
f:close()
end
-- add metadata to list
2023-04-27 05:01:37 +02:00
mcl_skins.register_simple_skin({
index = id,
2022-09-06 19:51:43 +02:00
texture = skin,
slim_arms = data and data.gender == "female",
2023-04-27 05:01:37 +02:00
})
2022-09-06 19:51:43 +02:00
id = id + 1
end
end
init_simple_skins()