Skip to content
Snippets Groups Projects
Commit fe4c644b authored by leroux raphael's avatar leroux raphael
Browse files

Add support for 3d_armor

parent f9787a93
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,10 @@ local WORLD_PATH = minetest.get_worldpath();
if MOD_NAME ~= "wardrobe" then
error("mod directory must be named 'wardrobe'");
end
local armor_mod = false;
if minetest.get_modpath("3d_armor") then armor_mod = true; end;
wardrobe = {};
dofile(MOD_PATH.."/storage.lua");
......@@ -21,7 +25,6 @@ do
local haveCharName = false; -- 'character.*' has priority
local name = nil;
local nNames = 0;
for k in pairs(default.registered_player_models) do
if string.find(k, "^character\\.[^\\.]+$") then
if haveCharName then nNames = 2; break; end;
......@@ -39,11 +42,14 @@ do
end;
function wardrobe.setPlayerSkin(player)
-- If 3d_armor is installed, let him set the model and textures
if armor_mod then return end
local playerName = player:get_player_name();
if not playerName or playerName == "" then return; end
if not playerName or playerName == "" then return; end;
local skin = wardrobe.playerSkins[playerName];
if not skin or not wardrobe.skinNames[skin] then return; end
if not skin or not wardrobe.skinNames[skin] then return; end;
player:set_properties(
{
......@@ -58,15 +64,21 @@ function wardrobe.changePlayerSkin(playerName, skin)
local player = minetest.get_player_by_name(playerName);
if not player then
error("unknown player '"..playerName.."'");
return;
end
if skin and not wardrobe.skinNames[skin] then
error("unknown skin '"..skin.."'");
return;
end
wardrobe.playerSkins[playerName] = skin;
wardrobe.storage.savePlayerSkins();
wardrobe.setPlayerSkin(player);
-- If 3d_armor is installed, update the skin texture and the armor
if armor_mod then
armor.textures[playerName].skin = skin;
armor:update_player_visuals(player);
else wardrobe.setPlayerSkin(player) end
end
minetest.register_on_joinplayer(
......@@ -77,4 +89,3 @@ minetest.register_on_joinplayer(
end,
player);
end);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment