summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/api.lua b/api.lua
index 492024f..549e79e 100644
--- a/api.lua
+++ b/api.lua
@@ -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