Merge pull request #23 from Thomas--S/item_description-fixes

Lua Controller: Fix $item_description() documentation and translation
This commit is contained in:
Joachim Stolberg 2020-08-08 12:07:40 +02:00 committed by GitHub
commit af451ef3bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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")'
})