diff options
author | Alexander Weber <web.alexander@web.de> | 2017-06-19 16:36:53 +0200 |
---|---|---|
committer | Alexander Weber <web.alexander@web.de> | 2017-06-19 16:37:38 +0200 |
commit | 897ac2c97bc419c1abdcb30228e0df602cc0046d (patch) | |
tree | 0a2b4632462fb25b7db5345dd7fe967251c90764 /api.lua | |
parent | 57b815f91ffd9bdd165c741350c6099f6b08685b (diff) |
API enhancements, player-attribute according naming convention
Diffstat (limited to 'api.lua')
-rw-r--r-- | api.lua | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -1,11 +1,11 @@ -- get current skin -skins.get_player_skin = function(player) - local skin = player:get_attribute("skin") +function skins.get_player_skin(player) + local skin = player:get_attribute("skinsdb:skin_key") return skins.get(skin) or skins.get(skins.default) end --- Set skin -skins.set_player_skin = function(player, skin) +-- Assign skin to player +function skins.assign_player_skin(player, skin) local skin_obj local skin_key if type(skin) == "string" then @@ -13,18 +13,22 @@ skins.set_player_skin = function(player, skin) else skin_obj = skin end - skin_key = skin:get_meta("_key") + skin_key = skin_obj:get_key() if skin_key == skins.default then skin_key = "" end - - player:set_attribute("skin", skin_key) - skins.update_player_skin(player) + player:set_attribute("skinsdb:skin_key", skin_key) end -- update visuals -skins.update_player_skin = function(player) +function skins.update_player_skin(player) local skin = skins.get_player_skin(player) skin:set_skin(player) end + +-- Assign and update +function skins.set_player_skin(player, skin) + skins.assign_player_skin(player, skin) + skins.update_player_skin(player) +end |