Allow character creator, homedecor and wardrobe mods to work together. – by auouymous
parent
8636079b5d
commit
369c088067
|
@ -42,6 +42,9 @@ local function changeWardrobeSkin(playerName, skin)
|
||||||
error("unknown skin '"..skin.."'");
|
error("unknown skin '"..skin.."'");
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
-- clear homedecor wardrobe skin
|
||||||
|
player:set_attribute("homedecor:player_skin", "")
|
||||||
|
|
||||||
wardrobe.playerSkins[playerName] = skin;
|
wardrobe.playerSkins[playerName] = skin;
|
||||||
wardrobe.storage.savePlayerSkins();
|
wardrobe.storage.savePlayerSkins();
|
||||||
end;
|
end;
|
||||||
|
@ -80,11 +83,23 @@ local SKIN_CHANGE_METHODS =
|
||||||
{
|
{
|
||||||
required_mods = { '3d_armor' },
|
required_mods = { '3d_armor' },
|
||||||
|
|
||||||
initSkin = nil,
|
initSkin = function(player)
|
||||||
|
local playerName = player:get_player_name()
|
||||||
|
if not playerName or playerName == "" then return end
|
||||||
|
local skin = wardrobe.playerSkins[playerName]
|
||||||
|
if not skin or not wardrobe.skinNames[skin] then return end
|
||||||
|
armor.textures[playerName].skin = skin
|
||||||
|
armor:update_player_visuals(player)
|
||||||
|
end,
|
||||||
|
|
||||||
changeSkin = function(playerName, skin)
|
changeSkin = function(playerName, skin)
|
||||||
changeWardrobeSkin(playerName, skin);
|
changeWardrobeSkin(playerName, skin);
|
||||||
armor.textures[playerName].skin = skin;
|
if skin == nil then
|
||||||
|
-- character creator skin will restore at next login, or now by pressing 'Done' in character creator
|
||||||
|
armor.textures[playerName].skin = armor.default_skin..".png"
|
||||||
|
else
|
||||||
|
armor.textures[playerName].skin = skin
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
updateSkin = function(player)
|
updateSkin = function(player)
|
||||||
|
|
|
@ -14,7 +14,7 @@ local function showForm(player, page)
|
||||||
local s = 1 + SKINS_PER_PAGE*(page-1);
|
local s = 1 + SKINS_PER_PAGE*(page-1);
|
||||||
local e = math.min(s+SKINS_PER_PAGE-1, n);
|
local e = math.min(s+SKINS_PER_PAGE-1, n);
|
||||||
|
|
||||||
local fs = "size[5,10]";
|
local fs = "size[5,11]";
|
||||||
fs = fs.."label[0,0;Change Into:]";
|
fs = fs.."label[0,0;Change Into:]";
|
||||||
for i = s, e do
|
for i = s, e do
|
||||||
local slot = i-s+1;
|
local slot = i-s+1;
|
||||||
|
@ -29,6 +29,7 @@ local function showForm(player, page)
|
||||||
if page < nPages then
|
if page < nPages then
|
||||||
fs = fs.."button_exit[4,9;1,1;n:p"..(page+1)..";next]";
|
fs = fs.."button_exit[4,9;1,1;n:p"..(page+1)..";next]";
|
||||||
end
|
end
|
||||||
|
fs = fs.."button_exit[0,10;5,1;c:c;clear]";
|
||||||
|
|
||||||
minetest.show_formspec(playerName, FORM_NAME, fs);
|
minetest.show_formspec(playerName, FORM_NAME, fs);
|
||||||
end
|
end
|
||||||
|
@ -52,6 +53,9 @@ minetest.register_on_player_receive_fields(
|
||||||
elseif action == "s" then
|
elseif action == "s" then
|
||||||
wardrobe.changePlayerSkin(playerName, value);
|
wardrobe.changePlayerSkin(playerName, value);
|
||||||
return;
|
return;
|
||||||
|
elseif action == "c" then
|
||||||
|
wardrobe.changePlayerSkin(playerName, nil);
|
||||||
|
return;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue