From 61e001dc6d16f36a014411f01e568f19fa4cc81e Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Mon, 3 Aug 2020 19:35:33 +0200 Subject: [PATCH] Lua Controller: Fix $item_description() documentation and translation --- init.lua | 8 ++++++++ lua_controller/commands.lua | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index b3f91c0..e6e4ef6 100644 --- a/init.lua +++ b/init.lua @@ -55,6 +55,14 @@ techage.S = minetest.get_translator("techage") -- Load mod storage techage.storage = minetest.get_mod_storage() +-- Ensure compatibility with older Minetest versions by providing +-- a dummy implementation of `minetest.get_translated_string`. +if not minetest.get_translated_string then + minetest.get_translated_string = function(lang_code, string) + return string + end +end + -- Basis features local MP = minetest.get_modpath("techage") dofile(MP.."/basis/lib.lua") -- helper functions diff --git a/lua_controller/commands.lua b/lua_controller/commands.lua index 584c338..2c20e72 100644 --- a/lua_controller/commands.lua +++ b/lua_controller/commands.lua @@ -189,13 +189,13 @@ techage.lua_ctlr.register_function("item_description", { cmnd = function(self, itemstring) local item_def = minetest.registered_items[itemstring] if item_def and item_def.description then - return item_def.description + return minetest.get_translated_string("en", item_def.description) end return "" end, help = " $item_description(itemstring)\n".. " Get the description for a specified itemstring.\n".. - ' example: desc = $itemstring("default:apple")' + ' example: desc = $item_description("default:apple")' })