Add changable skin color

This commit is contained in:
Wuzzy 2021-08-07 23:47:15 +02:00
parent 7b58bbb931
commit 36b4ef9c44
15 changed files with 29 additions and 4 deletions

View File

@ -100,6 +100,9 @@ local function on_joinplayer(player)
player_health[name] = player:get_hp() player_health[name] = player:get_hp()
player_lastpos[name] = player:get_pos() player_lastpos[name] = player:get_pos()
local inv = player:get_inventory()
inv:set_size("hand", 1)
end end
local function on_leaveplayer(player) local function on_leaveplayer(player)

View File

@ -1,2 +1,3 @@
default default
wieldhand
util util

View File

@ -20,8 +20,7 @@ function player_skins.get_skin(name)
end end
local components = { local components = {
--skin_colors = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, skin_colors = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" },
skin_colors = { "1" },
cloth_colors = { "red", "redviolet", "magenta", "purple", "blue", "cyan", "green", "yellow", "orange" }, cloth_colors = { "red", "redviolet", "magenta", "purple", "blue", "cyan", "green", "yellow", "orange" },
band_colors = { "red", "redviolet", "magenta", "purple", "blue", "skyblue", "cyan", "turquoise", "lime", "green", "yellow", "orange" }, band_colors = { "red", "redviolet", "magenta", "purple", "blue", "skyblue", "cyan", "turquoise", "lime", "green", "yellow", "orange" },
hairs = { hairs = {
@ -65,11 +64,16 @@ function player_skins.set_skin(name, skin, cloth, bands, hair, eyes)
if not player then if not player then
return false return false
end end
-- Set player skin and wieldhand
default.player_set_textures(player, { newskin }) default.player_set_textures(player, { newskin })
wieldhand.set_hand(player, skin)
-- Update internal data
player_skins.skins[name] = newskin player_skins.skins[name] = newskin
local meta = player:get_meta() local meta = player:get_meta()
local metastring = skin..","..eyes..","..hair..","..cloth..","..bands local metastring = skin..","..eyes..","..hair..","..cloth..","..bands
meta:set_string("player_skins:skindata", metastring) meta:set_string("player_skins:skindata", metastring)
if minetest.global_exists("armor") then if minetest.global_exists("armor") then
armor.update(player) armor.update(player)
end end
@ -126,9 +130,9 @@ function player_skins.get_formspec(playername)
form = form .. "model[0.2,0.5;4,8;player_skins_skin_select_model;character.b3d;"..player_skins.skins[playername]..";0,180;false;false;0,0;0]" form = form .. "model[0.2,0.5;4,8;player_skins_skin_select_model;character.b3d;"..player_skins.skins[playername]..";0,180;false;false;0,0;0]"
form = form .. default.ui.button(3.5, 0.3, 3, 1, "player_skins_skin_select_hairs", S("Hair")) form = form .. default.ui.button(3.5, 0.3, 3, 1, "player_skins_skin_select_hairs", S("Hair"))
form = form .. default.ui.button(3.5, 1.3, 3, 1, "player_skins_skin_select_eye_colors", S("Eyes")) form = form .. default.ui.button(3.5, 1.3, 3, 1, "player_skins_skin_select_eye_colors", S("Eyes"))
form = form .. default.ui.button(3.5, 2.3, 3, 1, "player_skins_skin_select_skin_colors", S("Skin"))
form = form .. default.ui.button(3.5, 3, 3, 1, "player_skins_skin_select_cloth_colors", S("Shirt")) form = form .. default.ui.button(3.5, 3, 3, 1, "player_skins_skin_select_cloth_colors", S("Shirt"))
form = form .. default.ui.button(3.5, 5, 3, 1, "player_skins_skin_select_band_colors", S("Trousers")) form = form .. default.ui.button(3.5, 5, 3, 1, "player_skins_skin_select_band_colors", S("Trousers"))
form = form .. default.ui.button(3.5, 6, 3, 1, "player_skins_skin_select_skin_colors", S("Skin"))
form = form .. default.ui.button(3.5, 7.75, 3, 1, "player_skins_skin_select_random", S("Random")) form = form .. default.ui.button(3.5, 7.75, 3, 1, "player_skins_skin_select_random", S("Random"))
return form return form
end end
@ -140,7 +144,7 @@ minetest.register_on_player_receive_fields(function(player, form_name, fields)
player_skins.set_random_skin(name) player_skins.set_random_skin(name)
changed = true changed = true
else else
local checks = {"hairs", "eye_colors", "cloth_colors", "band_colors"} local checks = {"hairs", "eye_colors", "cloth_colors", "band_colors", "skin_colors"}
for c=1, #checks do for c=1, #checks do
local check = checks[c] local check = checks[c]
if fields["player_skins_skin_select_"..check] then if fields["player_skins_skin_select_"..check] then

15
mods/wieldhand/init.lua Normal file
View File

@ -0,0 +1,15 @@
hand = {}
for h=0, 9 do
minetest.register_item("wieldhand:hand_"..h, {
type = "none",
wield_image = "wieldhand_"..h..".png",
wield_scale = {x=1.0,y=1.0,z=3.0},
})
end
function wieldhand.set_hand(player, skin_tone)
local inv = player:get_inventory()
local hand = ItemStack("wieldhand:hand_"..skin_tone)
inv:set_stack("hand", 1, hand)
end

2
mods/wieldhand/mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = wieldhand
description = Adds serveal wield hands for the different skin tones, to be used by player_skins mod

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B