Automatically change skin if the one a player's wearing is removed

This commit is contained in:
marco_a 2024-07-19 00:20:06 +02:00
parent 2f81629d2a
commit e150f0034f
7 changed files with 32 additions and 2 deletions

View File

@ -8,6 +8,7 @@ Wear=Tragen
##[ src/api.lua ]##
You've unlocked the skin @1!=
Your skin @1 has been removed...=
The skin you were wearing has been removed from you. A default skin has been put instead=
##[ src/commands.lua ]##
Skin @1 doesn't exist!=

View File

@ -8,6 +8,7 @@ Wear=Usar
##[ src/api.lua ]##
You've unlocked the skin @1!=
Your skin @1 has been removed...=
The skin you were wearing has been removed from you. A default skin has been put instead=
##[ src/commands.lua ]##
Skin @1 doesn't exist!=

View File

@ -8,6 +8,7 @@ Wear=Viselni
##[ src/api.lua ]##
You've unlocked the skin @1!=
Your skin @1 has been removed...=
The skin you were wearing has been removed from you. A default skin has been put instead=
##[ src/commands.lua ]##
Skin @1 doesn't exist!=

View File

@ -8,6 +8,7 @@ Wear=Indossa
##[ src/api.lua ]##
You've unlocked the skin @1!=Hai sbloccato l'aspetto @1!
Your skin @1 has been removed...=Ti è stato rimosso l'aspetto @1...
The skin you were wearing has been removed from you. A default skin has been put instead=L'aspetto che stavi indossando ti è stato rimosso. Ora ne hai uno predefinito
##[ src/commands.lua ]##
Skin @1 doesn't exist!=Non esiste nessun aspetto @1!

View File

@ -8,6 +8,7 @@ Wear=Ubierz
##[ src/api.lua ]##
You've unlocked the skin @1!=
Your skin @1 has been removed...=
The skin you were wearing has been removed from you. A default skin has been put instead=
##[ src/commands.lua ]##
Skin @1 doesn't exist!=

View File

@ -8,6 +8,7 @@ Wear=
##[ src/api.lua ]##
You've unlocked the skin @1!=
Your skin @1 has been removed...=
The skin you were wearing has been removed from you. A default skin has been put instead=
##[ src/commands.lua ]##
Skin @1 doesn't exist!=

View File

@ -177,7 +177,7 @@ end
function collectible_skins.remove_skin(p_name, skin_name)
try_to_load_player(p_name)
-- se la skin non esiste, annullo
-- se l'aspetto non esiste, annullo
if not loaded_skins[skin_name] then
collectible_skins.print_warning("There has been an attempt to remove player " .. p_name .. " a skin that doesn't exist (`" .. skin_name .. "`)!")
return end
@ -191,11 +191,24 @@ function collectible_skins.remove_skin(p_name, skin_name)
if not collectible_skins.has_skin(p_name, skin_name) then return end
local p_skins
local player = minetest.get_player_by_name(p_name)
-- se è online
if minetest.get_player_by_name(p_name) then
if player then
p_skins = players_skins[p_name]
minetest.chat_send_player(p_name, S("Your skin @1 has been removed...", loaded_skins[skin_name].name))
-- se ce l'aveva addosso, ne metto uno casuale tra i predefiniti
if equipped_skin[p_name] == skin_name then
for _, sk_name in ipairs(default_skins) do
if skin_name ~= sk_name and players_skins[p_name][sk_name] then
minetest.chat_send_player(p_name, S("The skin you were wearing has been removed from you. A default skin has been put instead"))
collectible_skins.set_skin(player, sk_name, true)
break
end
end
end
-- se è offline
else
p_skins = minetest.deserialize(storage:get_string(p_name))
@ -442,6 +455,17 @@ function load_player_data(player)
players_skins[p_name] = minetest.deserialize(storage:get_string(p_name))
end
-- se l'aspetto che aveva lə è stato rimosso, ne metto uno casuale tra i predefiniti
if not players_skins[p_name][skin_name] then
for _, sk_name in ipairs(default_skins) do
if players_skins[p_name][sk_name] then
skin_name = sk_name
minetest.chat_send_player(p_name, S("The skin you were wearing has been removed from you. A default skin has been put instead"))
break
end
end
end
collectible_skins.set_skin(player, skin_name, false, true)
end
end