diff options
author | bell07 <web.alexander@web.de> | 2018-05-10 15:14:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-10 15:14:51 +0200 |
commit | b12aefbe4fe768106ee1d1dfac8567dbbcd8c273 (patch) | |
tree | d5e63e14b9e2675129267ee69abc66c67cd8a13d /skin_meta_api.lua | |
parent | 45edbf808ac0a74e4da6b468c2bf87b8b49e02a0 (diff) | |
parent | 2c20692f33cadc75edf279e2f0bed032d083b56d (diff) |
Merge pull request #11 from bell07/V_1_8_skins
Added support for 1.8er Skins
Ok, just merge it without review
Diffstat (limited to 'skin_meta_api.lua')
-rw-r--r-- | skin_meta_api.lua | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/skin_meta_api.lua b/skin_meta_api.lua index d9ca875..f8a92e2 100644 --- a/skin_meta_api.lua +++ b/skin_meta_api.lua @@ -59,16 +59,51 @@ function skin_class:get_preview() return self._preview or "player.png" end -function skin_class:set_skin(player) +local armor_loaded = minetest.global_exists("armor") + +function skin_class:apply_skin_to_player(player) + local ver = self:get_meta("format") or "1.0" + default.player_set_model(player, "skinsdb_3d_armor_character.b3d") + + local v10_texture = "blank.png" + local v18_texture = "blank.png" + local armor_texture = "blank.png" + local wielditem_texture = "blank.png" + + if ver == "1.8" then + v18_texture = self:get_texture() + else + v10_texture = self:get_texture() + end + + if armor_loaded then + local armor_textures = armor.textures[player:get_player_name()] + if armor_textures then + armor_texture = armor_textures.armor + wielditem_texture = armor_textures.wielditem + end + end + + default.player_set_textures(player, { + v10_texture, + v18_texture, + armor_texture, + wielditem_texture, + }) + player:set_properties({ visual_size = { - x = 1, - y = 1 + x = self:get_meta("visual_size_x") or 1, + y = self:get_meta("visual_size_y") or 1 } }) - player:set_properties({ - textures = {self:get_texture()}, - }) +end + +function skin_class:set_skin(player) + -- The set_skin is used on skins selection + -- This means the method could be redefined to start an furmslec + -- See character_creator for example + self:apply_skin_to_player(player) end function skin_class:is_applicable_for_player(playername) |