Make a big cushion in combining 2 cushion slabs with sneak + right-click

This commit is contained in:
kilbith 2016-01-25 13:03:20 +01:00
parent fa0544f134
commit 18dd8582be
2 changed files with 21 additions and 1 deletions

View File

@ -172,6 +172,12 @@ xdecor.register("crate", {
sounds = default.node_sound_wood_defaults()
})
xdecor.register("cushion_block", {
tiles = {"xdecor_cushion.png"},
groups = {snappy=3, flammable=3, fall_damage_add_percent=-75, not_in_creative_inventory=1},
drop = "xdecor:cushion 2"
})
local function door_access(door)
return door:find("prison")
end

View File

@ -82,9 +82,23 @@ xdecor.register("cushion", {
on_place = minetest.rotate_node,
node_box = xdecor.nodebox.slab_y(0.5),
can_dig = dig,
on_rightclick = function(pos, node, clicker)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
pos.y = pos.y + 0
sit(pos, node, clicker)
local wield_item = clicker:get_wielded_item():get_name()
if wield_item == "xdecor:cushion" and clicker:get_player_control().sneak then
local player_name = clicker:get_player_name()
if minetest.is_protected(pos, player_name) then
minetest.record_protection_violation(pos, player_name)
return
end
minetest.set_node(pos, {name="xdecor:cushion_block", param2=node.param2})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
return itemstack
end
end
end
})