From a54c395e91f55e22a209c02386bdc97de14409cf Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 15 Dec 2024 12:47:45 +0100 Subject: [PATCH] show error message instead of crash if no formspec text supplied --- show_fs.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/show_fs.lua b/show_fs.lua index 3075712..b986b5a 100644 --- a/show_fs.lua +++ b/show_fs.lua @@ -35,6 +35,13 @@ end -- show formspec with highest possible version information for the player -- force_version: optional parameter yl_speak_up.show_fs_ver = function(pname, formname, formspec, force_version) + -- catch errors + if(not(formspec)) then + force_version = "1" + formspec = "size[4,2]label[0,0;Error: No text found for form\n\"".. + minetest.formspec_escape(formname).."\"]".. + "button_exit[1.5,1.5;1,0.5;exit;Exit]" + end -- if the formspec already calls for a specific formspec version: use that one if(string.sub(formspec, 1, 17) == "formspec_version[") then minetest.show_formspec(pname, formname, formspec)