From 7b87099f2ce90dd662e7e2c888e7cf6836b7e2cc Mon Sep 17 00:00:00 2001 From: luk3yx Date: Mon, 4 Dec 2023 08:22:43 +1300 Subject: Bugfix --- font_api/fontform.lua | 16 ++++++++-------- signs_api/init.lua | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/font_api/fontform.lua b/font_api/fontform.lua index d019fba..28b70d5 100644 --- a/font_api/fontform.lua +++ b/font_api/fontform.lua @@ -54,15 +54,15 @@ local function show_node_formspec(playername, pos) fs = fs:gsub("context", nodemeta) -- Change all ${} to their corresponding metadata values - local s, e - repeat - s, e = fs:find('%${.*}') - if s and e then - fs = fs:sub(1, s-1).. - minetest.formspec_escape(meta:get_string(fs:sub(s+2,e-1))).. - fs:sub(e+1) + fs = fs:gsub("(.)${(.*)}", function(prefix, key) + -- Don't alter escaped keys + if prefix == "\\" then + return prefix .. "${" .. key .. "}" end - until s == nil + + -- Get the node meta value + return prefix .. minetest.formspec_escape(meta:get_string(key)) + end) local context = get_context(playername) context.node_pos = pos diff --git a/signs_api/init.lua b/signs_api/init.lua index fd2db03..e5defc3 100644 --- a/signs_api/init.lua +++ b/signs_api/init.lua @@ -28,6 +28,11 @@ local FS = function(...) return minetest.formspec_escape(S(...)) end function signs_api.set_display_text(pos, text, font) local meta = minetest.get_meta(pos) + -- Horrible workaround to prevent the engine from trying to resolve + -- metadata keys + if text:sub(1, 2) == "${" and text:sub(-1) == "}" then + text = text .. " " + end meta:set_string("display_text", text) if text and text ~= "" then meta:set_string("infotext", "\""..text.."\"") -- cgit v1.2.3