From 323e230d49713401df7b2b04afe0a000de93992f Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sat, 9 Feb 2013 17:59:35 -0500 Subject: [PATCH] Add ability to place a sign directly onto a brass/wrought iron fencepost rather than crafting a sign-on-fencepost from one of each, how about just placing a sign directly onto a fencepost instead? This commit adds this. Place a brass or wrought iron fencepost, then attempt to place a sign against it. The fencepost will be replaced with one bearing the sign - in the same node. Dig to get the two pieces back as separate items, right click the placed sign to edit the text thereon. Note that as of this commit, there is a bug in minetest/builtin/item.lua that causes signs not to be deducted from your inventory on placement. --- crafts.lua | 21 --------------------- fences.lua | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/crafts.lua b/crafts.lua index b4b03471..1d8d1bda 100644 --- a/crafts.lua +++ b/crafts.lua @@ -1321,27 +1321,6 @@ minetest.register_craft( { }, }) --- the version of brass/wrought iron fences with signs attached - - -minetest.register_craft( { - type = "shapeless", - output = 'homedecor:fence_brass_with_sign', - recipe = { - 'homedecor:fence_brass', - 'default:sign_wall', - }, -}) - -minetest.register_craft( { - type = "shapeless", - output = 'homedecor:fence_wrought_iron_with_sign', - recipe = { - 'homedecor:fence_wrought_iron', - 'default:sign_wall', - }, -}) - -- other types of fences/gates minetest.register_craft( { diff --git a/fences.lua b/fences.lua index 382d70e0..764083d8 100644 --- a/fences.lua +++ b/fences.lua @@ -14,8 +14,27 @@ minetest.register_node("homedecor:fence_brass", { groups = {snappy=3}, sounds = default.node_sound_wood_defaults(), walkable = true, -}) + on_rightclick = function(pos, node, clicker) + local fdir = minetest.dir_to_facedir(clicker:get_look_dir()) + local itemstack = clicker:get_wielded_item() + if itemstack:get_name() == "default:sign_wall" then + minetest.env:add_node(pos, {name = "homedecor:fence_brass_with_sign", param2 = fdir}) + itemstack:take_item() + return itemstack + else + print("want to simply place the wielded item like usual.") + -- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally? + end + end, + on_place = function(itemstack, placer, pointed_thing) + local fdir = minetest.dir_to_facedir(placer:get_look_dir()) + minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_brass", param2 = fdir}) + itemstack:take_item() + placer:set_wielded_item(itemstack) + return itemstack + end +}) minetest.register_node("homedecor:fence_wrought_iron", { description = "Wrought Iron Fence/railing", @@ -31,6 +50,27 @@ minetest.register_node("homedecor:fence_wrought_iron", { groups = {snappy=3}, sounds = default.node_sound_wood_defaults(), walkable = true, + on_rightclick = function(pos, node, clicker) + local fdir = minetest.dir_to_facedir(clicker:get_look_dir()) + local itemstack = clicker:get_wielded_item() + if itemstack:get_name() == "default:sign_wall" then + minetest.env:add_node(pos, {name = "homedecor:fence_wrought_iron_with_sign", param2 = fdir}) + itemstack:take_item() + clicker:set_wielded_item(itemstack) + return itemstack + else + print("want to simply place the wielded item like usual.") + -- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally? + end + end, + + on_place = function(itemstack, placer, pointed_thing) + local fdir = minetest.dir_to_facedir(placer:get_look_dir()) + minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_wrought_iron", param2 = fdir}) + itemstack:take_item() + placer:set_wielded_item(itemstack) + return itemstack + end }) -- brass/wrought iron with signs: