Lua Controller: Fix $item_description() documentation and translation

This commit is contained in:
Thomas--S 2020-08-03 19:35:33 +02:00
parent 240c6e20ab
commit 61e001dc6d
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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")'
})