From 7f40f3404a8f9a53d01449296e37665d13223f52 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 3 Dec 2016 21:11:55 +0100 Subject: Gracefully fail when trying to parse unknown item --- init.lua | 5 +++++ locale/de.txt | 1 + locale/template.txt | 1 + 3 files changed, 7 insertions(+) diff --git a/init.lua b/init.lua index e5a46b4..0397a1d 100644 --- a/init.lua +++ b/init.lua @@ -104,6 +104,11 @@ end -- Extract suitable item description for formspec local description_for_formspec = function(itemstring) + if minetest.registered_items[itemstring] == nil then + -- Huh? The item doesn't exist for some reason. Better give a dummy string + minetest.log("warning", "[doc] Unknown item detected: "..tostring(itemstring)) + return S("Unknown item (@1)", tostring(itemstring)) + end local description = minetest.registered_items[itemstring].description if description == nil or description == "" then return minetest.formspec_escape(itemstring) diff --git a/locale/de.txt b/locale/de.txt index ef6dd3f..1b24416 100644 --- a/locale/de.txt +++ b/locale/de.txt @@ -121,6 +121,7 @@ any level = beliebige Stufe level 0 = Stufe 0 level 0-%d = Stufen 0-%d unknown = unbekannt +Unknown item (@1) = Unbekannter Gegenstand (@1) • %s: %d = • %s: %d • %s: %d HP = • %s: %d TP • %s: %s, %s = • %s: %s, %s diff --git a/locale/template.txt b/locale/template.txt index 0aa3b07..75c97ab 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -121,6 +121,7 @@ any level = level 0 = level 0-%d = unknown = +Unknown item (@1) = • %s: %d = • %s: %d HP = • %s: %s, %s = -- cgit v1.2.3