summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-05-13 09:37:58 -0400
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2018-05-13 09:37:58 -0400
commit61269f41d02ae14e8ba7799dda16cfee89a56e68 (patch)
treebd8867ffab9efaa9cf1db9869278328831b25e3c
parent6e95dd30cf8369102d1ce55d6549815ab9d31104 (diff)
downloaddreambuilder_modpack-61269f41d02ae14e8ba7799dda16cfee89a56e68.tar
dreambuilder_modpack-61269f41d02ae14e8ba7799dda16cfee89a56e68.tar.gz
dreambuilder_modpack-61269f41d02ae14e8ba7799dda16cfee89a56e68.tar.bz2
dreambuilder_modpack-61269f41d02ae14e8ba7799dda16cfee89a56e68.tar.xz
dreambuilder_modpack-61269f41d02ae14e8ba7799dda16cfee89a56e68.zip
updated homedecor
-rw-r--r--homedecor/depends.txt1
-rw-r--r--homedecor/wardrobe.lua38
-rw-r--r--itemframes/init.lua60
3 files changed, 74 insertions, 25 deletions
diff --git a/homedecor/depends.txt b/homedecor/depends.txt
index 7070b02..5a37ef6 100644
--- a/homedecor/depends.txt
+++ b/homedecor/depends.txt
@@ -12,3 +12,4 @@ bucket?
beds?
flowers?
3d_armor?
+skinsdb?
diff --git a/homedecor/wardrobe.lua b/homedecor/wardrobe.lua
index ef91ed8..40511d0 100644
--- a/homedecor/wardrobe.lua
+++ b/homedecor/wardrobe.lua
@@ -13,9 +13,29 @@ local set_player_textures =
or default.player_set_textures
local armor_mod_path = minetest.get_modpath("3d_armor")
-local skins = {"male1", "male2", "male3", "male4", "male5"}
+
+local skinslist = {"male1", "male2", "male3", "male4", "male5"}
local default_skin = "character.png"
+local skinsdb_mod_path = minetest.get_modpath("skinsdb")
+if skinsdb_mod_path then
+ for _, shrt in ipairs(skinslist) do
+ for _, prefix in ipairs({"", "fe"}) do
+ local skin_name = prefix..shrt
+ local skin_obj = skins.new("homedecor_clothes_"..skin_name..".png") -- Texture PNG file as key to be compatible in set_player_skin
+ skin_obj:set_preview("homedecor_clothes_"..skin_name.."_preview.png")
+ skin_obj:set_texture("homedecor_clothes_"..skin_name..".png")
+ skin_obj:set_meta("name", "Wardrobe "..skin_name)
+ skin_obj:set_meta("author", 'Calinou and Jordach')
+ skin_obj:set_meta("license", 'WTFPL')
+ local file = io.open(homedecor.modpath.."/textures/homedecor_clothes_"..skin_name..".png", "r")
+ skin_obj:set_meta("format", skins.get_skin_format(file))
+ file:close()
+ skin_obj:set_meta("in_inventory_list", false)
+ end
+ end
+end
+
function homedecor.get_player_skin(player)
local skin = player:get_attribute("homedecor:player_skin")
if not skin or skin == "" then
@@ -26,7 +46,9 @@ 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
+ if skinsdb_mod_path then
+ skins.set_player_skin(player, skin)
+ elseif 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
@@ -78,8 +100,8 @@ homedecor.register("wardrobe", {
local clothes_strings = ""
for i = 1,5 do
clothes_strings = clothes_strings..
- "image_button_exit["..(i-1)..".5,0;1.1,2;homedecor_clothes_"..skins[i].."_preview.png;"..skins[i]..";]"..
- "image_button_exit["..(i-1)..".5,2;1.1,2;homedecor_clothes_fe"..skins[i].."_preview.png;fe"..skins[i]..";]"
+ "image_button_exit["..(i-1)..".5,0;1.1,2;homedecor_clothes_"..skinslist[i].."_preview.png;"..skinslist[i]..";]"..
+ "image_button_exit["..(i-1)..".5,2;1.1,2;homedecor_clothes_fe"..skinslist[i].."_preview.png;fe"..skinslist[i]..";]"
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")).."]"..
@@ -97,11 +119,11 @@ homedecor.register("wardrobe", {
end
for i = 1,5 do
- if fields[skins[i]] then
- homedecor.set_player_skin(sender, "homedecor_clothes_"..skins[i]..".png", "player")
+ if fields[skinslist[i]] then
+ homedecor.set_player_skin(sender, "homedecor_clothes_"..skinslist[i]..".png", "player")
break
- elseif fields["fe"..skins[i]] then
- homedecor.set_player_skin(sender, "homedecor_clothes_fe"..skins[i]..".png", "player")
+ elseif fields["fe"..skinslist[i]] then
+ homedecor.set_player_skin(sender, "homedecor_clothes_fe"..skinslist[i]..".png", "player")
break
end
end
diff --git a/itemframes/init.lua b/itemframes/init.lua
index d26df19..21fac2f 100644
--- a/itemframes/init.lua
+++ b/itemframes/init.lua
@@ -32,6 +32,25 @@ minetest.register_entity("itemframes:item",{
if self.nodename == "itemframes:pedestal" then
self.object:set_properties({automatic_rotate = 1})
end
+ if self.texture ~= nil and self.nodename ~= nil then
+ local entity_pos = vector.round(self.object:get_pos())
+ local objs = minetest.get_objects_inside_radius(entity_pos, 0.5)
+ for _, obj in ipairs(objs) do
+ if obj ~= self.object and
+ obj:get_luaentity() and
+ obj:get_luaentity().name == "itemframes:item" and
+ obj:get_luaentity().nodename == self.nodename and
+ obj:get_properties() and
+ obj:get_properties().textures and
+ obj:get_properties().textures[1] == self.texture then
+ minetest.log("action","[itemframes] Removing extra " ..
+ self.texture .. " found in " .. self.nodename .. " at " ..
+ minetest.pos_to_string(entity_pos))
+ self.object:remove()
+ break
+ end
+ end
+ end
end,
get_staticdata = function(self)
if self.nodename ~= nil and self.texture ~= nil then
@@ -228,24 +247,31 @@ minetest.register_node("itemframes:pedestal",{
-- automatically restore entities lost from frames/pedestals
-- due to /clearobjects or similar
-
-minetest.register_abm({
+minetest.register_lbm({
+ label = "Maintain itemframe and pedestal entities",
+ name = "itemframes:maintain_entities",
nodenames = {"itemframes:frame", "itemframes:pedestal"},
- interval = 15,
- chance = 1,
- action = function(pos, node, active_object_count, active_object_count_wider)
- local num
-
- if node.name == "itemframes:frame" then
- num = #minetest.get_objects_inside_radius(pos, 0.5)
- elseif node.name == "itemframes:pedestal" then
- pos.y = pos.y + 1
- num = #minetest.get_objects_inside_radius(pos, 0.5)
- pos.y = pos.y - 1
- end
-
- if num > 0 then return end
- update_item(pos, node)
+ run_at_every_load = true,
+ action = function(pos, node)
+ minetest.after(0,
+ function(pos, node)
+ local meta = minetest.get_meta(pos)
+ local itemstring = meta:get_string("item")
+ if itemstring ~= "" then
+ local entity_pos = pos
+ if node.name == "itemframes:pedestal" then
+ entity_pos = {x=pos.x,y=pos.y+1,z=pos.z}
+ end
+ local objs = minetest.get_objects_inside_radius(entity_pos, 0.5)
+ if #objs == 0 then
+ minetest.log("action","[itemframes] Replacing missing " ..
+ itemstring .. " in " .. node.name .. " at " ..
+ minetest.pos_to_string(pos))
+ update_item(pos, node)
+ end
+ end
+ end,
+ pos, node)
end
})