diff --git a/basic_machines/ta4_chest.lua b/basic_machines/ta4_chest.lua index a9a0d86..868ebfa 100644 --- a/basic_machines/ta4_chest.lua +++ b/basic_machines/ta4_chest.lua @@ -65,6 +65,16 @@ local function get_count(nvm, idx) end end +local function get_itemstring(nvm, idx) + if idx and idx > 0 then + nvm.inventory = nvm.inventory or {} + if nvm.inventory[idx] then + return nvm.inventory[idx].name or "" + end + end + return "" +end + local function inv_empty(nvm) for _,item in ipairs(nvm.inventory or {}) do if item.count and item.count > 0 then @@ -552,6 +562,9 @@ techage.register_node({"techage:ta4_chest"}, { if topic == "count" then local nvm = techage.get_nvm(pos) return get_count(nvm, tonumber(payload) or 0) + elseif topic == "itemstring" then + local nvm = techage.get_nvm(pos) + return get_itemstring(nvm, tonumber(payload) or 0) elseif topic == "state" then local nvm = techage.get_nvm(pos) return inv_state(nvm) diff --git a/lua_controller/commands.lua b/lua_controller/commands.lua index 0058c95..584c338 100644 --- a/lua_controller/commands.lua +++ b/lua_controller/commands.lua @@ -185,6 +185,19 @@ techage.lua_ctlr.register_action("door", { " Hint: Use the Techage Programmer to\ndetermine the door position." }) +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 + end + return "" + end, + help = " $item_description(itemstring)\n".. + " Get the description for a specified itemstring.\n".. + ' example: desc = $itemstring("default:apple")' +}) + -- function not_protected(owner, number(s)) techage.lua_ctlr.not_protected = not_protected