From 2cff7234e017487934d1d1e95f6a312b41835e0d Mon Sep 17 00:00:00 2001 From: Lejo Date: Sat, 30 Jun 2018 16:15:57 +0200 Subject: Use Mod_storage --- api.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api.lua b/api.lua index 94b38e0..d1fd10b 100644 --- a/api.lua +++ b/api.lua @@ -1,6 +1,8 @@ -- get current skin +local storage = minetest.get_mod_storage() + function skins.get_player_skin(player) - local skin = player:get_attribute("skinsdb:skin_key") + local skin = storage:get_string(player:get_player_name()) return skins.get(skin) or skins.get(skins.default) end @@ -22,7 +24,7 @@ function skins.assign_player_skin(player, skin) if skin_key == skins.default then skin_key = "" end - player:set_attribute("skinsdb:skin_key", skin_key) + storage:set_string(player:get_player_name(), skin_key) else return false end -- cgit v1.2.3 From 91b1b695ab1e5fa3ce391ef06ad058cbbe45db0f Mon Sep 17 00:00:00 2001 From: Lejo Date: Sat, 30 Jun 2018 16:35:53 +0200 Subject: Make backward. --- api.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api.lua b/api.lua index d1fd10b..add2fa8 100644 --- a/api.lua +++ b/api.lua @@ -2,6 +2,10 @@ local storage = minetest.get_mod_storage() function skins.get_player_skin(player) + if player:get_attribute("skinsdb:skin_key") then + storage:set_string(player:get_player_name(), player:get_attribute("skinsdb:skin_key")) + player:set_attribute("skinsdb:skin_key", nil) + end local skin = storage:get_string(player:get_player_name()) return skins.get(skin) or skins.get(skins.default) end -- cgit v1.2.3