Beds : use default sleeping function and adjust s/c_box

This commit is contained in:
jp 2015-04-26 10:37:50 +02:00
parent f1428f7be7
commit ff6073664d

View File

@ -189,16 +189,34 @@ local bedcolors = {
"pink",
}
local bed_cbox = {
local bed_sbox = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 1.5 }
}
local kbed_cbox = {
local bed_cbox = {
type = "fixed",
fixed = {
{ -0.5, -0.5, -0.5, 0.5, -0.05, 1.5 },
{ -0.5, -0.5, 1.44, 0.5, 0.5, 1.5 },
{ -0.5, -0.5, -0.5, 0.5, 0.18, -0.44 },
}
}
local kbed_sbox = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 1.5, 0.5, 1.5 }
}
local kbed_cbox = {
type = "fixed",
fixed = {
{ -0.5, -0.5, -0.5, 1.5, -0.05, 1.5 },
{ -0.5, -0.5, 1.44, 1.5, 0.5, 1.5 },
{ -0.5, -0.5, -0.5, 1.5, 0.18, -0.44 },
}
}
for _, color in ipairs(bedcolors) do
local color2=color
if color == "darkgrey" then
@ -217,7 +235,7 @@ for _, color in ipairs(bedcolors) do
inventory_image = "homedecor_bed_"..color.."_inv.png",
description = S("Bed (%s)"):format(color),
groups = {snappy=3},
selection_box = bed_cbox,
selection_box = bed_sbox,
collision_box = bed_cbox,
after_place_node = function(pos, placer, itemstack, pointed_thing)
if not placer:get_player_control().sneak then
@ -227,6 +245,11 @@ for _, color in ipairs(bedcolors) do
after_dig_node = function(pos)
homedecor.unextend_bed(pos, color)
end,
on_rightclick = function(pos, node, clicker)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end
})
homedecor.register("bed_"..color.."_extended", {
@ -240,12 +263,17 @@ for _, color in ipairs(bedcolors) do
"wool_"..color2..".png^[brighten",
},
groups = {snappy=3, not_in_creative_inventory=1},
selection_box = bed_cbox,
selection_box = bed_sbox,
collision_box = bed_cbox,
expand = { forward = "air" },
after_dig_node = function(pos)
homedecor.unextend_bed(pos, color)
end,
on_rightclick = function(pos, node, clicker)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end,
drop = "homedecor:bed_"..color.."_regular"
})
@ -262,7 +290,7 @@ for _, color in ipairs(bedcolors) do
inventory_image = "homedecor_bed_kingsize_"..color.."_inv.png",
description = S("Bed (%s, king sized)"):format(color),
groups = {snappy=3, not_in_creative_inventory=1},
selection_box = kbed_cbox,
selection_box = kbed_sbox,
collision_box = kbed_cbox,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local inv = digger:get_inventory()
@ -271,6 +299,11 @@ for _, color in ipairs(bedcolors) do
inv:add_item("main", "homedecor:bed_"..color.."_regular 2")
end
end,
on_rightclick = function(pos, node, clicker)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end
})
minetest.register_alias("homedecor:bed_"..color.."_foot", "homedecor:bed_"..color.."_regular")