mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-12-23 08:20:21 +01:00
prepare code to be reused later
This commit is contained in:
parent
fe2acaaa1e
commit
ac10702849
@ -9,9 +9,21 @@ local wd_cbox = {
|
|||||||
-- cache set_textures function (fallback to old version)
|
-- cache set_textures function (fallback to old version)
|
||||||
-- default.player_set_textures is deprecated and will be removed in future
|
-- default.player_set_textures is deprecated and will be removed in future
|
||||||
local set_player_textures =
|
local set_player_textures =
|
||||||
minetest.global_exists("player_api") and player_api.set_textures
|
minetest.get_modpath("player_api") and player_api.set_textures
|
||||||
or default.player_set_textures
|
or default.player_set_textures
|
||||||
|
|
||||||
|
local armor_mod_path = minetest.get_modpath("3d_armor")
|
||||||
|
local skins = {"male1", "male2", "male3", "male4", "male5"}
|
||||||
|
|
||||||
|
local function set_player_skin(player, 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
|
||||||
|
end
|
||||||
|
|
||||||
homedecor.register("wardrobe", {
|
homedecor.register("wardrobe", {
|
||||||
mesh = "homedecor_bedroom_wardrobe.obj",
|
mesh = "homedecor_bedroom_wardrobe.obj",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -33,7 +45,6 @@ homedecor.register("wardrobe", {
|
|||||||
},
|
},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local skins = {"male1", "male2", "male3", "male4", "male5"}
|
|
||||||
-- textures made by the Minetest community (mostly Calinou and Jordach)
|
-- textures made by the Minetest community (mostly Calinou and Jordach)
|
||||||
local clothes_strings = ""
|
local clothes_strings = ""
|
||||||
for i = 1,5 do
|
for i = 1,5 do
|
||||||
@ -50,26 +61,12 @@ homedecor.register("wardrobe", {
|
|||||||
"listring[]")
|
"listring[]")
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
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")
|
|
||||||
|
|
||||||
for i = 1,5 do
|
for i = 1,5 do
|
||||||
if fields[skins[i]] then
|
if fields[skins[i]] then
|
||||||
if armor_mod then -- if 3D_armor's installed, let it set the skin
|
set_player_skin(sender, "homedecor_clothes_"..skins[i]..".png")
|
||||||
armor.textures[playerName].skin = "homedecor_clothes_"..skins[i]..".png"
|
|
||||||
armor:update_player_visuals(sender)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
set_player_textures(sender, { "homedecor_clothes_"..skins[i]..".png" })
|
|
||||||
break
|
break
|
||||||
elseif fields["fe"..skins[i]] then
|
elseif fields["fe"..skins[i]] then
|
||||||
if armor_mod then
|
set_player_skin(sender, "homedecor_clothes_fe"..skins[i]..".png")
|
||||||
armor.textures[playerName].skin = "homedecor_clothes_fe"..skins[i]..".png"
|
|
||||||
armor:update_player_visuals(sender)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
set_player_textures(sender, { skin = "homedecor_clothes_fe"..skins[i]..".png" })
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user