diff options
author | Alexander Weber <web.alexander@web.de> | 2017-06-16 23:00:36 +0200 |
---|---|---|
committer | Alexander Weber <web.alexander@web.de> | 2017-06-16 23:00:36 +0200 |
commit | 28d28390ce5d67f47db184cbbbc4ecd74be77eb2 (patch) | |
tree | 2dde0e088559a878d6006fa3f3779b5ac3adb1b0 /api.lua | |
parent | b267cf26579623565f5a85bee9e8584a5467a85f (diff) |
started work on skin_meta_api
Diffstat (limited to 'api.lua')
-rw-r--r-- | api.lua | 33 |
1 files changed, 15 insertions, 18 deletions
@@ -1,18 +1,25 @@ -- get current skin skins.get_player_skin = function(player) local skin = player:get_attribute("skin") - if not skins.textures[skin] then - skin = skins.default - end - return skin + return skins.get(skin) or skins.get(skins.default) end -- Set skin skins.set_player_skin = function(player, skin) - if skin == skins.default then - skin = "" + local skin_obj + local skin_key + if type(skin) == "string" then + skin_obj = skins.get(skin) or skins.get(skins.default) + else + skin_obj = skin + end + skin_key = skin:get_meta("_key") + + if skin_key == skins.default then + skin_key = "" end - player:set_attribute("skin", skin) + + player:set_attribute("skin", skin_key) skins.update_player_skin(player) end @@ -20,7 +27,7 @@ end skins.update_player_skin = function(player) local skin = skins.get_player_skin(player) player:set_properties({ - textures = {skins.textures[skin]}, + textures = {skin:get_texture()}, }) end @@ -28,13 +35,3 @@ end minetest.register_on_joinplayer(function(player) skins.update_player_skin(player) end) - --- 3d_armor compatibility -if minetest.global_exists("armor") then - armor.get_player_skin = function(self, name) - return skins.get_player_skin(minetest.get_player_by_name(name)) - end - armor.get_preview = function(self, name) - return skins.preview[skins.get_player_skin(minetest.get_player_by_name(name))] - end -end |