From 11bc97381f4d1393c941749c3aee0abea7e132d8 Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Fri, 19 Feb 2021 22:20:11 +0100 Subject: [PATCH] Signs: update and improve --- files/signs/init.lua | 52 ++++++++++++++--------- files/signs/textures/signs_item.png | Bin 0 -> 1585 bytes files/signs/textures/signs_sign.png | Bin 0 -> 1814 bytes files/signs/textures/signs_top.png | Bin 0 -> 966 bytes files/signs/textures/signs_wall_sign.png | Bin 0 -> 2155 bytes 5 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 files/signs/textures/signs_item.png create mode 100644 files/signs/textures/signs_sign.png create mode 100644 files/signs/textures/signs_top.png create mode 100644 files/signs/textures/signs_wall_sign.png diff --git a/files/signs/init.lua b/files/signs/init.lua index e1e2bf7..02b2703 100644 --- a/files/signs/init.lua +++ b/files/signs/init.lua @@ -8,9 +8,9 @@ if translator and not minetest.is_singleplayer() then end end -local vadd = vector.add local floor, pi = math.floor, math.pi -local find = string.find +local vadd = vector.add +local objects_inside_radius = minetest.get_objects_inside_radius local b = "blank.png" -- Cyrillic transliteration library @@ -67,10 +67,6 @@ local wrap_chars = { } local function generate_sign_texture(str) - if not str or str == "" then - return b - end - local row = 0 local texture = "[combine:" .. 16 * 20 .. "x100" local result = {} @@ -221,7 +217,7 @@ local function place(itemstack, placer, pointed_thing) end local function destruct(pos) - for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do + for _, obj in pairs(objects_inside_radius(pos, 0.5)) do local ent = obj:get_luaentity() if ent and ent.name == "signs:sign_text" then obj:remove() @@ -232,7 +228,7 @@ end local function check_text(pos) local meta = minetest.get_meta(pos) local text = meta:get_string("sign_text") - local objects = minetest.get_objects_inside_radius(pos, 0.5) + local objects = objects_inside_radius(pos, 0.5) if text and text ~= "" then local count = 0 @@ -266,6 +262,12 @@ local function check_text(pos) end end end + + -- Remove old on_construct fs + local fs = meta:get_string("formspec") + if fs and fs ~= "" then + meta:set_string("") + end end local function edit_text(pos, _, clicker) @@ -292,13 +294,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end local text = fields.Dtext - local pos = fields.spos + local pos = fields.spos and minetest.string_to_pos(fields.spos) if not text or not pos then return end - pos = minetest.string_to_pos(fields.spos) if minetest.is_protected(pos, player:get_player_name()) then return end @@ -307,7 +308,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local p2 = node.param2 local sign_pos = sign_positions - if find(node.name, "wall") then + if node.name:find("wall") then p2 = p2 - 2 sign_pos = wall_sign_positions end @@ -316,7 +317,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end local sign - for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do + for _, obj in pairs(objects_inside_radius(pos, 0.5)) do local ent = obj:get_luaentity() if ent and ent.name == "signs:sign_text" then sign = obj @@ -333,14 +334,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return end - -- Serialization longer values may cause a crash - -- because we are serializing the texture too - text = text:sub(1, 256) + local texture = b + if text ~= "" then + -- Serialization longer values may cause a crash + -- because we are serializing the texture too + text = text:sub(1, 256) + + texture = generate_sign_texture(text) + sign:set_properties({ + textures = {texture, b} + }) + end - local texture = generate_sign_texture(text) - sign:set_properties({ - textures = {texture, b} - }) sign:set_yaw(sign_pos[p2][2]) local meta = minetest.get_meta(pos) @@ -353,7 +358,12 @@ end) -- Sign nodes minetest.register_node("signs:sign", { description = S"Sign", - tiles = {"signs_wood.png"}, + tiles = { + "signs_top.png", "signs_top.png", "signs_top.png", + "signs_top.png", "signs_sign.png", "signs_sign.png" + }, + inventory_image = "signs_item.png", + wield_image = "signs_item.png", drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", @@ -375,7 +385,7 @@ minetest.register_node("signs:sign", { }) minetest.register_node("signs:wall_sign", { - tiles = {"signs_wood.png"}, + tiles = {"signs_wall_sign.png"}, drawtype = "nodebox", paramtype = "light", paramtype2 = "wallmounted", diff --git a/files/signs/textures/signs_item.png b/files/signs/textures/signs_item.png new file mode 100644 index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DaktOl$;L0qL%00000NkvXXu0mjf7rNUn literal 0 HcmV?d00001 diff --git a/files/signs/textures/signs_sign.png b/files/signs/textures/signs_sign.png new file mode 100644 index 0000000000000000000000000000000000000000..ea4dc74b1c72164bded26b0eba41100c33581973 GIT binary patch literal 1814 zcmZ`(c{JOJ8vUh3l&9J^mZFx|hjJL&Qtec2V{51+vP(#4ht?8H(K1D?*%uM9RvQva zED^Ba_wPmKwCb(r#P&;D72kN=n{}B^Pma=Nlb-T z(*oQ1A#xs}lOIw=fwko0g?Z3MCR$NQY~=*z=c11Zdfb_$3cg(1~ccsoD1o`Dk6 z0)LEf7gGbJEKGXnc{vZ?T0p2{pt=O1jcjaJ5lO}kYT{sPX^0MfNYP#YdIqxkKo=54 zxo9y3F3S&+9^~ZUS_^`kS=iVh$ErM7F4?Uz55`FHu4kb|dGJOSrji0{Vq-fCNwhc* zITzQ=4QgPZ+IWO&Y9KAvqnV9q;RZ>$xYm5ULO_%-P_%fDYD!=&4OyN6iw$x}CVt0= z`~G20K&ODz!o@wv2`EmxT9OWH=3oo&K!ka)4n9$E_bU6AH}{seoQvnD`jw_bB{U@K zmKQ7D^M00pRUWkA;BH);^-Lo5pgd3#0*VCOSEeHXKvfgs<$+33iYE^jn-dIu7JBBk zRL-3miu7j`8r3*KfHQaVqW504;cDOHvs%9OP0mlEN&I8ip zis6)FJbg7+U|nxAgnODy)3;2}84y@Gm}H()Fv04N3(^sHRx&fwJdZ&9-v$qzHOb9F z3GgQUj%en$j+%A8yBzc08AV2KO~{Hrv*?_OtxW=g0xm)Pp@>YiaNvtMrK2N~%5A~s zWBE`{%wVM${t0Liizs0c$xL&J6M6IZ#4%V#SX*^*64Vo;)BWsK#k8HwFQvN{tCIG! z0dIMsD)lv4pV%`yQ8wE2N9K;_P?Pfz+oUy1m%1%aZFF!W+ zjTZXz+mts&`Qf|2#C^gQs5Lz=HYz9ggT44Sdu^(>E*qg55RJO%ze3idG@lYccABG{ z)9U^vW>Lu&-yvM&oqR$I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0QH=>UZ{ch~olfs*=Q z=)=RDMbh3)pJaeWZ!Ww_2YyA>Tz{CP1Hg1-vH+X|oC2Or(}5Vp*#RYaH7YV|{D$&s ze65`)0U!W=QN(FGN&xDjh_*&)8UVo-fLXze3V<1OF0TmY5Dg>R0Up9SZLlQR?-v3p z)m2P*%%-`#>R@|+29*ffQ5W`GdkdJ)zKP9cBPyhu4a~pTY%VpQ!nKo~9 zMmr8X2zy8c?Aub`wr?dbx;@oWK~*x@w*79r>`3qLJof1NV(-B17;Xk0^edGS?%v&( zs8)C9WZ}`vBS}&t=@C^&(Y=?X*Wbj<{@@$$vf(;jog2J--(@aIa?kemSV*c=+III| z(FswuEKyEjvg#kMU-(#e$4BDIONG|TqAWfGvp!#_+n(4k@HNz7ZB8Fecf?~3_pTW< z&8Ls%lCcy>(3`WiOPhzF&9fg5taYBs48PO;*N2>|?AtCs(t*vnZJwnAVCP+=*tVSm zFtIn%feKJbIsio}WdQ9XtuoJgqcU=ULMqZXaWx5LeFH)gbvocG>Z}&1D{1^C1JH}! z(KZ=CrS41jGXR>!$g|yKV2j!|YdLR0i(W$dWO9%RPR|V<7{!dF~ o27q0wP%;qoER|0J|Nr0nfAAzL6*1(-fB*mh07*qoM6N<$f?K4^hyVZp literal 0 HcmV?d00001 diff --git a/files/signs/textures/signs_wall_sign.png b/files/signs/textures/signs_wall_sign.png new file mode 100644 index 0000000000000000000000000000000000000000..afd17597e0de2ac97f5651c1131873098cbd835a GIT binary patch literal 2155 zcmV-x2$c7UP)rL%x0GI>g-)Y}PmFLwsf$#egH5rHShzBReEMXgl#{fg-@e}P_~p^ zx0GLvaz&JPNu`HSsEJd#mS1jJG?jZyua8-ZZ$gN0L706{u#H%XbVZhXOPhXAZdo&R zUOAI_N{n(uoPkT99~-&=0004WQchCyH(|#}Usbd)9hbS-b;eGOd zf=h<)&ypkhc=&t*o~NZQBFZ zLMao5Vx~lme*Vb;+#Cr>2DBfMH1AWj0 zYIkgNXF0)p29tAIIKaPfh04u+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