From f6e85db33d436899679b9ee69e006fe253d8851b Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Wed, 11 Jun 2014 00:06:56 -0400 Subject: [PATCH] Add hanging-from-the-ceiling sign point at the ceiling while placing a regular sign and it becomes a ceiling- mounted one handing from a pair of short chains. --- signs_lib/init.lua | 67 ++++++++++++++++++-- signs_lib/textures/signs_hanging_back.png | Bin 0 -> 261 bytes signs_lib/textures/signs_hanging_bottom.png | Bin 0 -> 90 bytes signs_lib/textures/signs_hanging_front.png | Bin 0 -> 245 bytes signs_lib/textures/signs_hanging_side.png | Bin 0 -> 104 bytes signs_lib/textures/signs_hanging_top.png | Bin 0 -> 90 bytes 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 signs_lib/textures/signs_hanging_back.png create mode 100644 signs_lib/textures/signs_hanging_bottom.png create mode 100644 signs_lib/textures/signs_hanging_front.png create mode 100644 signs_lib/textures/signs_hanging_side.png create mode 100644 signs_lib/textures/signs_hanging_top.png diff --git a/signs_lib/init.lua b/signs_lib/init.lua index fe356e2..f945735 100644 --- a/signs_lib/init.lua +++ b/signs_lib/init.lua @@ -223,6 +223,13 @@ local signs = { {delta = {x = -0.399, y = 0.15, z = 0 }, yaw = math.pi / 2}, } +local signs_hanging = { + {delta = {x = 0, y = 0.032, z = -0.05}, yaw = 0}, + {delta = {x = -0.05, y = 0.032, z = 0 }, yaw = math.pi / -2}, + {delta = {x = 0, y = 0.032, z = 0.05}, yaw = math.pi}, + {delta = {x = 0.05, y = 0.032, z = 0 }, yaw = math.pi / 2}, +} + local signs_yard = { {delta = {x = 0, y = 0.15, z = -0.05}, yaw = 0}, {delta = {x = -0.05, y = 0.15, z = 0 }, yaw = math.pi / -2}, @@ -426,6 +433,8 @@ signs_lib.update_sign = function(pos, fields) local sign_info if minetest.get_node(pos).name == "signs:sign_yard" then sign_info = signs_yard[minetest.get_node(pos).param2 + 1] + elseif minetest.get_node(pos).name == "signs:sign_hanging" then + sign_info = signs_hanging[minetest.get_node(pos).param2 + 1] elseif minetest.get_node(pos).name == "default:sign_wall" then sign_info = signs[minetest.get_node(pos).param2 + 1] else --if minetest.get_node(pos).name == "signs:sign_post" then @@ -509,10 +518,8 @@ minetest.register_node(":default:sign_wall", { sign_info = signs_post[fdir + 1] elseif wdir == 0 then - --how would you add sign to ceiling? - minetest.add_item(above, "default:sign_wall") - itemstack:take_item() - return itemstack + minetest.add_node(above, {name = "signs:sign_hanging", param2 = fdir}) + sign_info = signs_hanging[fdir + 1] elseif wdir == 1 then minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir}) sign_info = signs_yard[fdir + 1] @@ -603,6 +610,58 @@ minetest.register_node(":signs:sign_yard", { end, }) +minetest.register_node(":signs:sign_hanging", { + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + drawtype = "nodebox", + node_box = {type = "fixed", fixed = { + {-0.45, 0.3124, 0, 0.45, 0.5, 0}, + {-0.45, -0.2875, -0.049, 0.45, 0.3125, 0.049} + }}, + selection_box = { + type = "fixed", + fixed = {-0.45, -0.275, -0.049, 0.45, 0.5, 0.049} + }, + tiles = { + "signs_hanging_top.png", + "signs_hanging_bottom.png", + "signs_hanging_side.png", + "signs_hanging_side.png", + "signs_hanging_back.png", + "signs_hanging_front.png" + }, + groups = {choppy=2, dig_immediate=2}, + drop = "default:sign_wall", + + on_construct = function(pos) + signs_lib.construct_sign(pos) + end, + on_destruct = function(pos) + signs_lib.destruct_sign(pos) + end, + on_receive_fields = function(pos, formname, fields, sender) + if fields and fields.text then + minetest.log("action", S("%s wrote \"%s\" to sign at %s"):format( + (sender:get_player_name() or ""), + fields.text, + minetest.pos_to_string(pos) + )) + end + if minetest.is_protected(pos, sender:get_player_name()) then + minetest.record_protection_violation(pos, + sender:get_player_name()) + return + end + if fields and fields.text then + signs_lib.update_sign(pos, fields) + end + end, + on_punch = function(pos, node, puncher) + signs_lib.update_sign(pos) + end, +}) + minetest.register_node(":signs:sign_post", { paramtype = "light", sunlight_propagates = true, diff --git a/signs_lib/textures/signs_hanging_back.png b/signs_lib/textures/signs_hanging_back.png new file mode 100644 index 0000000000000000000000000000000000000000..9f52ff87c4052dc8c694e74df0c25a587f111b5b GIT binary patch literal 261 zcmV+g0s8)lP)StCMw9-DpV=Q_gMoy_w1H?M4p5>%LF494m*(ERd+(K@ zMI6VqUgyxqn< z7Q4v(Ai+0gJS)sV6orAaW0K}?#=NRb*Uj>*aL+6R;i^k`{LvWbvY9}ax)Z%}7jE}9 z!FKIW3T-O8XdAz(41^%?sSRg^=?X0G8?y6pS%0!T=NW(fNPmDQ8y!ytQgQA`00000 LNkvXXu0mjf9;R*n literal 0 HcmV?d00001 diff --git a/signs_lib/textures/signs_hanging_bottom.png b/signs_lib/textures/signs_hanging_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..af5923eeeed3a2d8044cb019598a9f33c31a3da6 GIT binary patch literal 90 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|ik>cxAsXkC|NQ@N&#c+d+2~@R nWNN@RYs1AGZ5KNhx3V$V1hOsu!sTfRRLtP%>gTe~DWM4fw;UM! literal 0 HcmV?d00001 diff --git a/signs_lib/textures/signs_hanging_front.png b/signs_lib/textures/signs_hanging_front.png new file mode 100644 index 0000000000000000000000000000000000000000..1d98fc64ab244b08ad3b813609adee658974ad7f GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`dpunnLo7}wr!+9t*Z==-@a5Z)+zC1im1%<`3scd2?yzzGX+qIn7oh*3M8)yD| zt8UypqeCIg^@ZNUhoUW;HThjwGX>i~hJ5(IwW#9plc~E4Zhw$!@I8FB{e6H*)@kmC pCJlw9t#&8l8Y11M8b|;=G0`#Dz>90^H=sWlJYD@<);T3K0RZV>Ukd;L literal 0 HcmV?d00001 diff --git a/signs_lib/textures/signs_hanging_side.png b/signs_lib/textures/signs_hanging_side.png new file mode 100644 index 0000000000000000000000000000000000000000..a5098fbc1488c3bd999e86515ead1639f4e896c0 GIT binary patch literal 104 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|`kpS1AsXkC|NQ@N&&gZ literal 0 HcmV?d00001 diff --git a/signs_lib/textures/signs_hanging_top.png b/signs_lib/textures/signs_hanging_top.png new file mode 100644 index 0000000000000000000000000000000000000000..29428825f6ec707f6a071f61e99c7e5fd86b5b2d GIT binary patch literal 90 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|ik>cxAsXkC|NQ@N&#c+d+2~@R nWNP3R@%hq?wu>E$TiF;ALfCdxzih|_DrWF>^>bP0l+XkK&Z-(q literal 0 HcmV?d00001