From 36b4ef9c44ef78d88c90b30566751ed896df4c39 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 7 Aug 2021 23:47:15 +0200 Subject: [PATCH] Add changable skin color --- mods/default/player.lua | 3 +++ mods/player_skins/depends.txt | 1 + mods/player_skins/init.lua | 12 ++++++++---- mods/wieldhand/init.lua | 15 +++++++++++++++ mods/wieldhand/mod.conf | 2 ++ mods/wieldhand/textures/wieldhand_0.png | Bin 0 -> 198 bytes mods/wieldhand/textures/wieldhand_1.png | Bin 0 -> 188 bytes mods/wieldhand/textures/wieldhand_2.png | Bin 0 -> 196 bytes mods/wieldhand/textures/wieldhand_3.png | Bin 0 -> 196 bytes mods/wieldhand/textures/wieldhand_4.png | Bin 0 -> 194 bytes mods/wieldhand/textures/wieldhand_5.png | Bin 0 -> 194 bytes mods/wieldhand/textures/wieldhand_6.png | Bin 0 -> 194 bytes mods/wieldhand/textures/wieldhand_7.png | Bin 0 -> 194 bytes mods/wieldhand/textures/wieldhand_8.png | Bin 0 -> 199 bytes mods/wieldhand/textures/wieldhand_9.png | Bin 0 -> 199 bytes 15 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 mods/wieldhand/init.lua create mode 100644 mods/wieldhand/mod.conf create mode 100644 mods/wieldhand/textures/wieldhand_0.png create mode 100644 mods/wieldhand/textures/wieldhand_1.png create mode 100644 mods/wieldhand/textures/wieldhand_2.png create mode 100644 mods/wieldhand/textures/wieldhand_3.png create mode 100644 mods/wieldhand/textures/wieldhand_4.png create mode 100644 mods/wieldhand/textures/wieldhand_5.png create mode 100644 mods/wieldhand/textures/wieldhand_6.png create mode 100644 mods/wieldhand/textures/wieldhand_7.png create mode 100644 mods/wieldhand/textures/wieldhand_8.png create mode 100644 mods/wieldhand/textures/wieldhand_9.png diff --git a/mods/default/player.lua b/mods/default/player.lua index f0b5701..eef8eb3 100644 --- a/mods/default/player.lua +++ b/mods/default/player.lua @@ -100,6 +100,9 @@ local function on_joinplayer(player) player_health[name] = player:get_hp() player_lastpos[name] = player:get_pos() + + local inv = player:get_inventory() + inv:set_size("hand", 1) end local function on_leaveplayer(player) diff --git a/mods/player_skins/depends.txt b/mods/player_skins/depends.txt index b7cc57f..1332f76 100644 --- a/mods/player_skins/depends.txt +++ b/mods/player_skins/depends.txt @@ -1,2 +1,3 @@ default +wieldhand util diff --git a/mods/player_skins/init.lua b/mods/player_skins/init.lua index da0f171..931390d 100644 --- a/mods/player_skins/init.lua +++ b/mods/player_skins/init.lua @@ -20,8 +20,7 @@ function player_skins.get_skin(name) end local components = { - --skin_colors = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, - skin_colors = { "1" }, + skin_colors = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, 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" }, hairs = { @@ -65,11 +64,16 @@ function player_skins.set_skin(name, skin, cloth, bands, hair, eyes) if not player then return false end + -- Set player skin and wieldhand default.player_set_textures(player, { newskin }) + wieldhand.set_hand(player, skin) + + -- Update internal data player_skins.skins[name] = newskin local meta = player:get_meta() local metastring = skin..","..eyes..","..hair..","..cloth..","..bands meta:set_string("player_skins:skindata", metastring) + if minetest.global_exists("armor") then armor.update(player) 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 .. 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, 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, 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")) return form end @@ -140,7 +144,7 @@ minetest.register_on_player_receive_fields(function(player, form_name, fields) player_skins.set_random_skin(name) changed = true 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 local check = checks[c] if fields["player_skins_skin_select_"..check] then diff --git a/mods/wieldhand/init.lua b/mods/wieldhand/init.lua new file mode 100644 index 0000000..0a7ec71 --- /dev/null +++ b/mods/wieldhand/init.lua @@ -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 diff --git a/mods/wieldhand/mod.conf b/mods/wieldhand/mod.conf new file mode 100644 index 0000000..713546f --- /dev/null +++ b/mods/wieldhand/mod.conf @@ -0,0 +1,2 @@ +name = wieldhand +description = Adds serveal wield hands for the different skin tones, to be used by player_skins mod diff --git a/mods/wieldhand/textures/wieldhand_0.png b/mods/wieldhand/textures/wieldhand_0.png new file mode 100644 index 0000000000000000000000000000000000000000..5b8d0189ac23e43a7b7cad3d898381458157aecd GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP#2fL^^kD=19^FX0sPZ!4!i_^(}{{OdUR&D5PbUM(a zx1q9L-KttuOvC;$I%tuw8#;85&Qj|<$77VU}1t^WDT k`0HMStOF|;d4Pc7=skXyyt774K;s!aUHx3vIVCg!0P^5NfB*mh literal 0 HcmV?d00001 diff --git a/mods/wieldhand/textures/wieldhand_1.png b/mods/wieldhand/textures/wieldhand_1.png new file mode 100644 index 0000000000000000000000000000000000000000..1bc9c9d9b3dabba60dc9a06a9827d4c0827e3ab1 GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP#2fL^^tH(d5Y@m>*r;B5V#p&cf|Nq-Ft2T5tIvr@z z+fZ4_7stDAV(cM`+Z*PveTU9>1+rIw){n{U0{`|_0`W_vh60iPz^i};; hb>fwVKxPRbV2CdjI=%WteLm1|22WQ%mvv4FO#q6VLpcBd literal 0 HcmV?d00001 diff --git a/mods/wieldhand/textures/wieldhand_3.png b/mods/wieldhand/textures/wieldhand_3.png new file mode 100644 index 0000000000000000000000000000000000000000..c2ae28efe0d1a297f0bcad779412d25e5b464a33 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP#2fL`aW%@+BH$b64PZ!4!i_^(}{{OdUR&D5PbUM(a zx1q9L-KttubB`+NQW`+N1h{`|_0`W#$EiC2IA`)mHH hI`K+FAhQGzFywOx6?-kSe*`p~!PC{xWt~$(699cJLGu6r literal 0 HcmV?d00001 diff --git a/mods/wieldhand/textures/wieldhand_4.png b/mods/wieldhand/textures/wieldhand_4.png new file mode 100644 index 0000000000000000000000000000000000000000..14e737531f918100bf63da05c5b61c32dbb25f84 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP#2fL_*=%tH(2Y^EUo-U3d7N?W{{QqyytlH4o=yae- zZ$o7zUmWkgiNPPF4*-FJ>cM`+Z*PveTU9>%@{|4l$Lhw$i3`MASa)vBs{8#<`|DnV ftOF|;d4PbS^o4+HZ+B%Z&}arvS3j3^P6KBf>9H5ZDr;B5V#p&cf|Nq-Ft2T5tIvr@z z+fZ4_7stDAV(%a;|9w1;~;1iIN+H&tD&}arvS3j3^P6cM`+Z*PveTU90=-F5l@$Lhw$i3`MkR9I}t`uF82``5h& gSqD}y@&ExtlN0}&9?h`(K%*HvUHx3vIVCg!03-H7hX4Qo literal 0 HcmV?d00001 diff --git a/mods/wieldhand/textures/wieldhand_7.png b/mods/wieldhand/textures/wieldhand_7.png new file mode 100644 index 0000000000000000000000000000000000000000..99b955e6ebfe7e2e1f842600043b28333796b943 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP#2fL^w&-#Ve9f3mro-U3d7N?W{{QqyytlH4o=yae- zZ$o7zUmWkgiNPPF4*-FJ>cM`+Z*PveTU93h+m!tOV|8QW#0BCNJ8y2x`uFFn`q#Y% gSqD}y@&EyYn*jf{HCvb80~*cX>FVdQ&MBb@04sAtN&o-= literal 0 HcmV?d00001 diff --git a/mods/wieldhand/textures/wieldhand_8.png b/mods/wieldhand/textures/wieldhand_8.png new file mode 100644 index 0000000000000000000000000000000000000000..7eafce9ffd1ee9527b5a0155ca730c278419ec04 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP#2fL`G>`}q*n}I?ho-U3d7N?W{{QqyytlH4o=yae- zZ$o7zUmWkgiNPPF4*-FJ>cM`+Z*Pve->PU7v=y+8E&0&)>YHu21ZP!ad$;WBXZrW+ jg6?xKX6umxDQ93Xt`U}>dpTMUXg-6dtDnm{r-UW|2XI1B literal 0 HcmV?d00001 diff --git a/mods/wieldhand/textures/wieldhand_9.png b/mods/wieldhand/textures/wieldhand_9.png new file mode 100644 index 0000000000000000000000000000000000000000..42480e29200cce3cb4a153c60afabeeeec61c846 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP#2fL`GR_&UgJwTxlPZ!4!i_^(}{{OdUR&D5PbUM(a zx1q9L-KZ&fr3+6u_#T>04cs!`colC!F@dou6pXZiQ* j1MhP$X6umxDQ93Xh!K`wyZ&}G(0m3@S3j3^P6y1Kb literal 0 HcmV?d00001