From d4f7de464007dfc4d8842f21625a0ca00a1c8218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Fri, 22 Mar 2013 14:37:44 -0300 Subject: [PATCH 1/2] fix wrong check for protection on node placement --- signs_lib.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/signs_lib.lua b/signs_lib.lua index 2a672b6f..09504a35 100644 --- a/signs_lib.lua +++ b/signs_lib.lua @@ -144,11 +144,6 @@ minetest.register_node(":default:sign_wall", { itemstack:take_item() return itemstack elseif wdir == 1 then - local def = minetest.registered_nodes[minetest.env:get_node(pointed_thing.above).name] - if homedecor_node_is_owned(pointed_thing.above, placer) - or (not def.buildable_to) then - return - end minetest.env:add_node(above, {name = "signs:sign_yard", param2 = fdir}) sign_info = signs_yard[fdir + 1] else @@ -156,6 +151,12 @@ minetest.register_node(":default:sign_wall", { sign_info = signs[fdir + 1] end + local def = minetest.registered_nodes[minetest.env:get_node(pointed_thing.above).name] + if homedecor_node_is_owned(pointed_thing.above, placer) + or (not def.buildable_to) then + return + end + local text = minetest.env:add_entity({x = above.x + sign_info.delta.x, y = above.y + sign_info.delta.y, z = above.z + sign_info.delta.z}, "signs:text") From 1ce512a3c86e89cad13476020bdd35a05b11bba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Fri, 22 Mar 2013 14:49:57 -0300 Subject: [PATCH 2/2] add logging support to signslib and re-add intllib support --- locale/es.txt | 2 ++ locale/fr.txt | 2 ++ locale/template.txt | 2 ++ signs_lib.lua | 34 ++++++++++++++++++++++++++++++++-- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/locale/es.txt b/locale/es.txt index 96a1e3f4..49ec8aef 100644 --- a/locale/es.txt +++ b/locale/es.txt @@ -176,3 +176,5 @@ Small CRT Television = Pequeña Televisión CRT E: character map file not found = E: archivo de mapa de caracteres no encontrado ## 1: Full String, 2: pos in string, 3: current char at pos W: unknown symbol in '%s' at %d (probably %s) = A: símbolo desconocido en '%s' posición %d (probablemente %s) +%s wrote "%s" to sign at %s = %s ha escrito "%s" en el letrero en %s +signs loaded = letreros cargados diff --git a/locale/fr.txt b/locale/fr.txt index fed1410b..2a17a282 100644 --- a/locale/fr.txt +++ b/locale/fr.txt @@ -176,3 +176,5 @@ Small CRT Television = Petite télévision à tube cathodique E: character map file not found = E: fichier de table de caractère non trouvé ## 1: Full String, 2: pos in string, 3: current char at pos W: unknown symbol in '%s' at %d (probably %s) = A: symbole inconnu dans '%s' dans %d (probablement %s) +%s wrote "%s" to sign at %s = +signs loaded = diff --git a/locale/template.txt b/locale/template.txt index 864e2858..7a82f3a3 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -180,3 +180,5 @@ Small CRT Television = E: character map file not found = ## 1: Full String, 2: pos in string, 3: current char at pos W: unknown symbol in '%s' at %d (probably %s) = +%s wrote "%s" to sign at %s = +signs loaded = diff --git a/signs_lib.lua b/signs_lib.lua index 09504a35..7f98475b 100644 --- a/signs_lib.lua +++ b/signs_lib.lua @@ -1,11 +1,20 @@ -- Font: 04.jp.org +-- Boilerplate to support localized strings if intllib mod is installed. +local S +if (minetest.get_modpath("intllib")) then + dofile(minetest.get_modpath("intllib").."/intllib.lua") + S = intllib.Getter(minetest.get_current_modname()) +else + S = function ( s ) return s end +end + -- load characters map local chars_file = io.open(minetest.get_modpath("homedecor").."/characters", "r") local charmap = {} local max_chars = 16 if not chars_file then - print("[signs] E: character map file not found") + print("[signs] "..S("E: character map file not found")) else while true do local char = chars_file:read("*l") @@ -173,6 +182,13 @@ minetest.register_node(":default:sign_wall", { homedecor_destruct_sign(pos) end, on_receive_fields = function(pos, formname, fields, sender) + if fields then + print(S("%s wrote \"%s\" to sign at %s"):format( + (sender:get_player_name() or ""), + fields.text, + minetest.pos_to_string(pos) + )) + end homedecor_update_sign(pos, fields) end, on_punch = function(pos, node, puncher) @@ -201,6 +217,13 @@ minetest.register_node(":signs:sign_yard", { homedecor_destruct_sign(pos) end, on_receive_fields = function(pos, formname, fields, sender) + if fields then + print(S("%s wrote \"%s\" to sign at %s"):format( + (sender:get_player_name() or ""), + fields.text, + minetest.pos_to_string(pos) + )) + end homedecor_update_sign(pos, fields) end, on_punch = function(pos, node, puncher) @@ -402,6 +425,13 @@ function homedecor_register_fence_with_sign(fencename, fencewithsignname) homedecor_destruct_sign(pos) end def_sign.on_receive_fields = function(pos, formname, fields, sender, ...) + if fields then + print(S("%s wrote \"%s\" to sign at %s"):format( + (sender:get_player_name() or ""), + fields.text, + minetest.pos_to_string(pos) + )) + end homedecor_update_sign(pos, fields) end def_sign.on_punch = function(pos, node, puncher, ...) @@ -419,5 +449,5 @@ function homedecor_register_fence_with_sign(fencename, fencewithsignname) end if minetest.setting_get("log_mods") then - minetest.log("action", "signs loaded") + minetest.log("action", S("signs loaded")) end