feat: default_label_resolver reads name property; item-template convention
The default label_resolver now reads the optional player-facing `name` property from the item-template; modules with named templates get pretty row labels without registering an override. Falls back to "Item" when `name` is absent or empty. README documents the player-facing item-template convention: name, description, weight, volume, composition.<material> — all optional, all with documented defaults. Skill-gated description reveals stay on the separate hints lib (designed, not yet implemented).
This commit is contained in:
9
init.lua
9
init.lua
@@ -81,9 +81,14 @@ local function default_icon_resolver(item)
|
||||
end
|
||||
|
||||
-- default_label_resolver(item) -> string
|
||||
-- v0.1: no public composition.template_of accessor exists. Module
|
||||
-- overrides via set_label_resolver to provide pretty names.
|
||||
-- Reads the player-facing `name` property from the item-template. Modules
|
||||
-- that declare `name` on their item-templates get pretty names automatically;
|
||||
-- modules without `name` get the generic "Item" fallback.
|
||||
-- Override via set_label_resolver for custom mappings (template-id, lookup
|
||||
-- table, localization, …).
|
||||
local function default_label_resolver(item)
|
||||
local name = item:get_property("name")
|
||||
if name and name ~= "" then return name end
|
||||
return "Item"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user