Editing Module:Sandbox/Monster Domosed/AbilityTable/ComplexRenderersGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 404: | Line 404: | ||
end | end | ||
-- Memoized | -- Memoized display-name lookup that calls Module:Lang's get_string with the prop | ||
-- AbilityData.json records only carry { Value, Scale }; the human-readable | -- key suffixed by "_label" (e.g. "MaxDamageBeforePerfect_label"). The flat | ||
-- AbilityData.json records only carry { Value, Scale }; the localized, | |||
-- human-readable prop name is a Lang string keyed by the prop key + "_label". | |||
-- | -- The module is required lazily so this file can still load when Lang is absent | ||
local | -- (e.g. module console), in which case the fallback to the raw key applies. | ||
local function | local Lang = nil | ||
if | local _label_lookup = nil | ||
local function prop_label(key) | |||
if _label_lookup == nil then _label_lookup = {} end | |||
if _label_lookup[key] ~= nil then return _label_lookup[key] end | |||
if | |||
if Lang == nil then | |||
local ok, mod = pcall(require, "Module:Lang") | |||
if ok and type(mod) == "table" then Lang = mod end | |||
if type( | |||
end | end | ||
if Lang and type(Lang.get_string) == "function" then | |||
local ok, label = pcall(Lang.get_string, key .. "_label") | |||
if ok and type(label) == "string" and label ~= "" then | |||
_label_lookup[key] = label | |||
return label | |||
local | |||
if type( | |||
end | end | ||
end | end | ||
return | -- Cache the miss (as nil) so we don't hit Lang again for this key. | ||
_label_lookup[key] = nil | |||
return nil | |||
end | end | ||
| Line 479: | Line 467: | ||
and type(scale["Value"]) == "number" | and type(scale["Value"]) == "number" | ||
and scale["Value"] ~= 0 then | and scale["Value"] ~= 0 then | ||
-- Prefer a Name carried directly on the prop, then any | -- Prefer a Name carried directly on the prop, then any name | ||
-- recovered from nested Key/ | -- recovered from nested Key/Name entries inside this record, | ||
-- | -- then the localized Lang label for "<key>_label", else the key. | ||
local label = type(v["Name"]) == "string" and v["Name"] | local label = type(v["Name"]) == "string" and v["Name"] | ||
or names[k] | or names[k] | ||
or | or prop_label(k) | ||
or k | or k | ||
table.insert(props, { key = k, value = scale["Value"], name = label }) | table.insert(props, { key = k, value = scale["Value"], name = label }) | ||