summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbell07 <web.alexander@web.de>2018-07-02 15:42:33 +0200
committerGitHub <noreply@github.com>2018-07-02 15:42:33 +0200
commit0cb00a3a9b9c69529e757f6dccbffc05fa430064 (patch)
tree922009d065cc6449d8c2657abee740e3f63d1f69
parent2900d789af3e56fb07695cf140a2a86aee279801 (diff)
parent91b1b695ab1e5fa3ce391ef06ad058cbbe45db0f (diff)
Merge pull request #17 from Lejo1/mod_storage
Use Mod_storage The mod storage is preferred above the player storage because of possibility to set skins for offline players . Thanks @Lejo1
-rw-r--r--api.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/api.lua b/api.lua
index 94b38e0..add2fa8 100644
--- a/api.lua
+++ b/api.lua
@@ -1,6 +1,12 @@
-- get current skin
+local storage = minetest.get_mod_storage()
+
function skins.get_player_skin(player)
- local skin = player:get_attribute("skinsdb:skin_key")
+ 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
@@ -22,7 +28,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