diff options
author | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2018-05-11 10:22:53 -0400 |
---|---|---|
committer | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2018-05-11 10:22:53 -0400 |
commit | 249daeb0e6a7d9b637eeb4e5cfda4710a68d59d3 (patch) | |
tree | 915217a9657158d2a02eb8d93507944f618d5142 /homedecor | |
parent | af2fedcf9998bb4a854c2cfd63e4cdad91a6dd5d (diff) | |
download | dreambuilder_modpack-249daeb0e6a7d9b637eeb4e5cfda4710a68d59d3.tar dreambuilder_modpack-249daeb0e6a7d9b637eeb4e5cfda4710a68d59d3.tar.gz dreambuilder_modpack-249daeb0e6a7d9b637eeb4e5cfda4710a68d59d3.tar.bz2 dreambuilder_modpack-249daeb0e6a7d9b637eeb4e5cfda4710a68d59d3.tar.xz dreambuilder_modpack-249daeb0e6a7d9b637eeb4e5cfda4710a68d59d3.zip |
Add readme.md mostly taken from the forum thread (and markdown-ified)
Updated several mods: castles, homedecor, digilines, farming redo,
jumping, maptools, mesecons, moreblocks, moretrees, pipeworks,
signs_lib, technic, unified_dyes
Deleted the peaceful_npc mod, as it is broken and unmaintained.
Diffstat (limited to 'homedecor')
-rw-r--r-- | homedecor/wardrobe.lua | 81 |
1 files changed, 65 insertions, 16 deletions
diff --git a/homedecor/wardrobe.lua b/homedecor/wardrobe.lua index d0e3538..ef91ed8 100644 --- a/homedecor/wardrobe.lua +++ b/homedecor/wardrobe.lua @@ -6,6 +6,53 @@ local wd_cbox = { fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 } } +-- cache set_textures function (fallback to old version) +-- default.player_set_textures is deprecated and will be removed in future +local set_player_textures = + minetest.get_modpath("player_api") and player_api.set_textures + or default.player_set_textures + +local armor_mod_path = minetest.get_modpath("3d_armor") +local skins = {"male1", "male2", "male3", "male4", "male5"} +local default_skin = "character.png" + +function homedecor.get_player_skin(player) + local skin = player:get_attribute("homedecor:player_skin") + if not skin or skin == "" then + return default_skin, true + end + return skin, false +end + +function homedecor.set_player_skin(player, skin, save) + skin = skin or default_skin + if armor_mod_path then -- if 3D_armor's installed, let it set the skin + armor.textures[player:get_player_name()].skin = skin + armor:update_player_visuals(player) + else + set_player_textures(player, { skin }) + end + + if save then + if skin == default_skin then + skin = "default" + player:set_attribute("homedecor:player_skin", "") + else + player:set_attribute("homedecor:player_skin", skin) + end + if save == "player" then -- if player action + minetest.log("verbose", + S("player @1 sets skin to @2", player:get_player_name(), skin) .. + (armor_mod_path and ' [3d_armor]' or '') + ) + end + end +end + +function homedecor.unset_player_skin(player) + homedecor.set_player_skin(player, nil, true) +end + homedecor.register("wardrobe", { mesh = "homedecor_bedroom_wardrobe.obj", tiles = { @@ -27,7 +74,6 @@ homedecor.register("wardrobe", { }, on_construct = function(pos) local meta = minetest.get_meta(pos) - local skins = {"male1", "male2", "male3", "male4", "male5"} -- textures made by the Minetest community (mostly Calinou and Jordach) local clothes_strings = "" for i = 1,5 do @@ -37,6 +83,7 @@ homedecor.register("wardrobe", { end meta:set_string("formspec", "size[5.5,8.5]"..default.gui_bg..default.gui_bg_img..default.gui_slots.. "vertlabel[0,0.5;"..minetest.formspec_escape(S("Clothes")).."]".. + "button_exit[0,3.29;0.6,0.6;default;x]".. clothes_strings.. "vertlabel[0,5.2;"..minetest.formspec_escape(S("Storage")).."]".. "list[current_name;main;0.5,4.5;5,2;]".. @@ -44,26 +91,17 @@ homedecor.register("wardrobe", { "listring[]") end, on_receive_fields = function(pos, formname, fields, sender) - local skins = {"male1", "male2", "male3", "male4", "male5"} - local playerName = sender:get_player_name() - local armor_mod = minetest.get_modpath("3d_armor") + if fields.default then + homedecor.set_player_skin(sender, nil, "player") + return + end for i = 1,5 do if fields[skins[i]] then - if armor_mod then -- if 3D_armor's installed, let it set the skin - armor.textures[playerName].skin = "homedecor_clothes_"..skins[i]..".png" - armor:update_player_visuals(sender) - break - end - default.player_set_textures(sender, { "homedecor_clothes_"..skins[i]..".png" }) + homedecor.set_player_skin(sender, "homedecor_clothes_"..skins[i]..".png", "player") break elseif fields["fe"..skins[i]] then - if armor_mod then - armor.textures[playerName].skin = "homedecor_clothes_fe"..skins[i]..".png" - armor:update_player_visuals(sender) - break - end - default.player_set_textures(sender, { skin = "homedecor_clothes_fe"..skins[i]..".png" }) + homedecor.set_player_skin(sender, "homedecor_clothes_fe"..skins[i]..".png", "player") break end end @@ -72,3 +110,14 @@ homedecor.register("wardrobe", { minetest.register_alias("homedecor:wardrobe_bottom", "homedecor:wardrobe") minetest.register_alias("homedecor:wardrobe_top", "air") + +minetest.register_on_joinplayer(function(player) + local skin = player:get_attribute("homedecor:player_skin") + + if skin and skin ~= "" then + -- setting player skin on connect has no effect, so delay skin change + minetest.after(1, function(player, skin) + homedecor.set_player_skin(player, skin) + end, player, skin) + end +end) |