MineClone2/mods/PLAYER/mcl_skins/mesh_hand.lua

65 lines
2.0 KiB
Lua
Raw Normal View History

2022-09-06 19:51:43 +02:00
local function make_texture(base, colorspec)
local output = ""
if mcl_skins.masks[base] then
output = mcl_skins.masks[base] ..
"^[colorize:" .. minetest.colorspec_to_colorstring(colorspec) .. ":alpha"
end
if #output > 0 then output = output .. "^" end
output = output .. base
return output
end
function mcl_skins.get_skin_list()
local list = {}
2023-01-11 19:31:56 +01:00
for _, game_mode in pairs({"_crea", "_surv"}) do
for _, base in pairs(mcl_skins.base) do
for _, base_color in pairs(mcl_skins.base_color) do
2023-04-27 05:01:37 +02:00
local id = base:gsub(".png$", "")
.. minetest.colorspec_to_colorstring(base_color):gsub("#", "")
2023-01-11 19:31:56 +01:00
local female = {
texture = make_texture(base, base_color),
slim_arms = true,
id = id .. "_female" .. game_mode,
creative = game_mode == "_crea"
}
table.insert(list, female)
local male = {
texture = make_texture(base, base_color),
slim_arms = false,
id = id .. "_male" .. game_mode,
creative = game_mode == "_crea"
}
table.insert(list, male)
end
end
for _, skin in pairs(mcl_skins.simple_skins) do
table.insert(list, {
texture = skin.texture,
slim_arms = skin.slim_arms,
2023-04-27 05:01:37 +02:00
id = skin.texture:gsub(".png$", "")
.. (skin.slim_arms and "_female" or "_male") .. game_mode,
creative = game_mode == "_crea"
2023-01-11 19:31:56 +01:00
})
2022-09-06 19:51:43 +02:00
end
end
return list
end
function mcl_skins.get_node_id_by_player(player)
2023-04-27 05:01:37 +02:00
local skin = mcl_skins.player_skins[player]
local simple_skin = skin.simple_skins_id
if simple_skin then
2023-04-27 05:01:37 +02:00
skin = mcl_skins.texture_to_simple_skin[skin.simple_skins_id]
end
2023-01-11 19:31:56 +01:00
local creative = minetest.is_creative_enabled(player:get_player_name())
local append = (skin.slim_arms and "_female" or "_male") .. (creative and "_crea" or "_surv")
if simple_skin then
2023-01-11 19:31:56 +01:00
return skin.texture:gsub(".png$", "") .. append
2022-09-06 19:51:43 +02:00
else
return skin.base:gsub(".png$", "") ..
2023-01-11 19:31:56 +01:00
minetest.colorspec_to_colorstring(skin.base_color):gsub("#", "") .. append
2022-09-06 19:51:43 +02:00
end
end