From 76b0435163fa0a42d721781f0bc6457466c4a334 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sun, 17 Aug 2014 15:53:22 -0400 Subject: [PATCH] add locked wall sign, drop-in replacement for the old locked_sign mod except because they used the old legacy wallmount draw type, you will have to use the screwdriver to rotate these signs after updating. --- signs_lib/init.lua | 98 +++++++++++++++++++-- signs_lib/textures/signs_bottom_locked.png | Bin 0 -> 111 bytes signs_lib/textures/signs_front_locked.png | Bin 0 -> 438 bytes signs_lib/textures/signs_locked_inv.png | Bin 0 -> 453 bytes signs_lib/textures/signs_side_locked.png | Bin 0 -> 149 bytes signs_lib/textures/signs_top_locked.png | Bin 0 -> 119 bytes 6 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 signs_lib/textures/signs_bottom_locked.png create mode 100644 signs_lib/textures/signs_front_locked.png create mode 100644 signs_lib/textures/signs_locked_inv.png create mode 100644 signs_lib/textures/signs_side_locked.png create mode 100644 signs_lib/textures/signs_top_locked.png diff --git a/signs_lib/init.lua b/signs_lib/init.lua index dbd972c..31715d9 100644 --- a/signs_lib/init.lua +++ b/signs_lib/init.lua @@ -456,7 +456,7 @@ local function set_obj_text(obj, text, new) }) end -signs_lib.construct_sign = function(pos) +signs_lib.construct_sign = function(pos, locked) local meta = minetest.get_meta(pos) meta:set_string( "formspec", @@ -487,14 +487,18 @@ local function make_infotext(text) return table.concat(lines2, "\n") end -signs_lib.update_sign = function(pos, fields) +signs_lib.update_sign = function(pos, fields, owner) local meta = minetest.get_meta(pos) + local new if fields then fields.text = trim_input(fields.text) - meta:set_string("infotext", make_infotext(fields.text).." ") + local ownstr = "" + if owner then ownstr = "Locked sign, owned by "..owner.."\n" end + + meta:set_string("infotext", ownstr..make_infotext(fields.text).." ") meta:set_string("text", fields.text) meta:set_int("__signslib_new_format", 1) new = true @@ -615,19 +619,25 @@ function signs_lib.determine_sign_type(itemstack, placer, pointed_thing) end end -function signs_lib.receive_fields(pos, formname, fields, sender) +function signs_lib.receive_fields(pos, formname, fields, sender, lock) if minetest.is_protected(pos, sender:get_player_name()) then minetest.record_protection_violation(pos, sender:get_player_name()) return end + lockstr = "" + if lock then lockstr = "locked " end if fields and fields.text and fields.ok then - minetest.log("action", S("%s wrote \"%s\" to sign at %s"):format( + minetest.log("action", S("%s wrote \"%s\" to "..lockstr.."sign at %s"):format( (sender:get_player_name() or ""), fields.text, minetest.pos_to_string(pos) )) - signs_lib.update_sign(pos, fields) + if lock then + signs_lib.update_sign(pos, fields, sender:get_player_name()) + else + signs_lib.update_sign(pos, fields) + end end end @@ -748,6 +758,60 @@ minetest.register_node(":signs:sign_post", { }, }) +-- Locked wall sign + +minetest.register_privilege("sign_editor", "Can edit all locked signs") + +minetest.register_node(":locked_sign:sign_wall_locked", { + description = S("Sign"), + inventory_image = "signs_locked_inv.png", + wield_image = "signs_locked_inv.png", + node_placement_prediction = "", + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + drawtype = "nodebox", + node_box = signs_lib.wall_sign_model.nodebox, + tiles = { + "signs_top_locked.png", + "signs_bottom_locked.png", + "signs_side_locked.png", + "signs_side.png", + "signs_back.png", + "signs_front_locked.png" + }, + groups = sign_groups, + on_place = function(itemstack, placer, pointed_thing) + return signs_lib.determine_sign_type(itemstack, placer, pointed_thing) + end, + on_construct = function(pos) + signs_lib.construct_sign(pos, true) + end, + on_destruct = function(pos) + signs_lib.destruct_sign(pos) + end, + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") + local pname = sender:get_player_name() or "" + if pname ~= owner and pname ~= minetest.setting_get("name") + and not minetest.check_player_privs(pname, {sign_editor=true}) then + return + end + signs_lib.receive_fields(pos, formname, fields, sender, true) + end, + on_punch = function(pos, node, puncher) + signs_lib.update_sign(pos) + end, + can_dig = function(pos, player) + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") + local pname = player:get_player_name() + return pname == owner or pname == minetest.setting_get("name") + or minetest.check_player_privs(pname, {sign_editor=true}) + end, +}) + -- metal, colored signs local sign_colors = { "green", "yellow", "red", "white_red", "white_black" } @@ -886,6 +950,7 @@ end build_char_db() minetest.register_alias("homedecor:fence_wood_with_sign", "signs:sign_post") +minetest.register_alias("sign_wall_locked", "locked_sign:sign_wall_locked") signs_lib.register_fence_with_sign("default:fence_wood", "signs:sign_post") @@ -900,6 +965,27 @@ minetest.register_abm({ end }) +-- locked sign + +minetest.register_craft({ + output = "locked_sign:sign_wall_locked", + recipe = { + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "group:wood", "default:steel_ingot"}, + {"", "group:stick", ""}, + } +}) + +--Alternate recipe. + +minetest.register_craft({ + output = "locked_sign:sign_wall_locked", + recipe = { + {"default:sign_wall"}, + {"default:steel_ingot"}, + }, +}) + -- craft recipes for the metal signs minetest.register_craft( { diff --git a/signs_lib/textures/signs_bottom_locked.png b/signs_lib/textures/signs_bottom_locked.png new file mode 100644 index 0000000000000000000000000000000000000000..9b3d40efdb025978e549cc05e316f0dea353b068 GIT binary patch literal 111 zcmeAS@N?(olHy`uVBq!ia0vp^0wBx*Bp9q_EZ7UA%sgEjLnJOIpV@Wr@Bzg`AHF|T zmt$MzZ)3z$!r1fTno--yn$(1ZivMv_A8Ruk9}j1<+R1!3ilLKDbos-j4;n!xdAj^S+=_GRT2Sk zgKHb=`WjA2#)3e0ef|2XC*W{6>~^~#2!8rL03r&4V7*=w(c9af>*0v#!}~uyhEI>- gKP~>hzx4UQJMx~)uCyWlSpWb407*qoM6N<$f)^6bjQ{`u literal 0 HcmV?d00001 diff --git a/signs_lib/textures/signs_locked_inv.png b/signs_lib/textures/signs_locked_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..b87a35591f943a6dbe8d67ad65e066616dfcbf66 GIT binary patch literal 453 zcmV;$0XqJPP)CW{#2RRRY2D7l=^;cX5PFa$3WV#onJ28SW&(R#P!&SGLIbA+UJ zKUMYBPgTJ`9|B;v+u5qB2!a49B>;CF$1z%KuGj0U#^dqGe!mwkzC<`9r7&2GO&Dj^I}sv+y)5LK-2Z4 zIw#A-1W41Am2|1ff@m>EawDA28M+dLOWT>zRTOx%ogs>X3D7hR(ZdR*6vh~4j{yjY zbz5qk5G_|ABuXi=UuUA_iu3u$1Te;M<3`)mUg@oFXsKT95g=-fT7#!1FwscOUt#KTx)Y+F0zLYjk~w>v*)L zCC$@OtG};sxm-w+gd|DWyzL2=5de0uw6&(|E3g4d2z+1B^%YM~*#tP9P8<#geBbAb v=K-L##`k@;+bvpao}YiddL*qi|4IA?bf?T(DKrjP00000NkvXXu0mjfE;7W< literal 0 HcmV?d00001 diff --git a/signs_lib/textures/signs_side_locked.png b/signs_lib/textures/signs_side_locked.png new file mode 100644 index 0000000000000000000000000000000000000000..0d3ee791c47f39b84a0eb03756fdcf92822ed8fd GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^0wBx*Bp9q_EZ7UAVmw_OLnJQuo?j?^xl@LnJOIui1C#@By`>AHIJS zmt$+wx8dR`VeENvZIg}h-$MsJe1B?PyG@@bCnx^jrIWIqr{X0fBpzHdVqp08MWVjc Rh=UtsqNl5$%Q~loCIEo(DQ5rx literal 0 HcmV?d00001