more elegant way to check for a global

This commit is contained in:
Alexsandro Percy 2024-10-05 14:22:43 -03:00
parent dbc03948c4
commit e0eb4c0bea

View file

@ -97,11 +97,11 @@ function airutils.set_player_skin(player, skin)
else else
--remove texture --remove texture
local old_texture = player_meta:get_string("backup") local old_texture = player_meta:get_string("backup")
if set_skin then --checking if set_skin is available (not using an optional dependency, just checking if it exists) if minetest.global_exists(set_skin) then --checking if set_skin is available
if player:get_attribute("set_skin:player_skin") ~= nil and player:get_attribute("set_skin:player_skin") ~= "" then if player:get_attribute("set_skin:player_skin") ~= nil and player:get_attribute("set_skin:player_skin") ~= "" then
old_texture = player:get_attribute("set_skin:player_skin") old_texture = player:get_attribute("set_skin:player_skin")
end end
elseif wardrobe then --checking if wardrobe is available (not using an optional dependency, just checking if it exists) elseif minetest.global_exists(wardrobe) then --checking if wardrobe is available
if wardrobe.playerSkins then if wardrobe.playerSkins then
if wardrobe.playerSkins[name] ~= nil then if wardrobe.playerSkins[name] ~= nil then
old_texture = wardrobe.playerSkins[name] old_texture = wardrobe.playerSkins[name]