mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2025-04-16 00:40:22 +02:00
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
This commit is contained in:
commit
0cb00a3a9b
10
api.lua
10
api.lua
@ -1,6 +1,12 @@
|
|||||||
-- get current skin
|
-- get current skin
|
||||||
|
local storage = minetest.get_mod_storage()
|
||||||
|
|
||||||
function skins.get_player_skin(player)
|
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)
|
return skins.get(skin) or skins.get(skins.default)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -22,7 +28,7 @@ function skins.assign_player_skin(player, skin)
|
|||||||
if skin_key == skins.default then
|
if skin_key == skins.default then
|
||||||
skin_key = ""
|
skin_key = ""
|
||||||
end
|
end
|
||||||
player:set_attribute("skinsdb:skin_key", skin_key)
|
storage:set_string(player:get_player_name(), skin_key)
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user