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 | ||
-- | -- Resolves the human-readable display Name for a prop key. Prefers the prop's | ||
-- | -- own "Name" field on the top-level table; otherwise recurses through the whole | ||
-- | -- ability record looking for any entry of the form { Key = key, Name = str } | ||
-- (e.g. prop entries inside Info1/Info2 ... .Main.Props). Falls back to the key. | |||
local function find_prop_name(ability, key) | |||
local direct = ability[key] | |||
local function | if type(direct) == "table" and type(direct["Name"]) == "string" then | ||
return direct["Name"] | |||
if type( | |||
return | |||
end | end | ||
local found | |||
local | |||
local function walk(node) | local function walk(node) | ||
if type(node) ~= "table" | if found or type(node) ~= "table" then return end | ||
for _, v in pairs(node) do | for _, v in pairs(node) do | ||
if type(v) == "table" then walk(v) end | if type(v) == "table" then | ||
if v["Key"] == key and type(v["Name"]) == "string" then | |||
found = v["Name"] | |||
return | |||
end | |||
walk(v) | |||
end | |||
end | end | ||
end | end | ||
walk( | walk(ability) | ||
return | return found or key | ||
end | end | ||
| Line 454: | Line 440: | ||
function p.RenderSpiritScaling(ability) | function p.RenderSpiritScaling(ability) | ||
local props = {} | local props = {} | ||
-- Gather every base Spirit-scaling instance (skip the Upgrades table). | -- Gather every base Spirit-scaling instance (skip the Upgrades table). | ||
| Line 479: | Line 449: | ||
and type(scale["Value"]) == "number" | and type(scale["Value"]) == "number" | ||
and scale["Value"] ~= 0 then | and scale["Value"] ~= 0 then | ||
local label = find_prop_name(ability, k) | |||
local label = | |||
table.insert(props, { key = k, value = scale["Value"], name = label }) | table.insert(props, { key = k, value = scale["Value"], name = label }) | ||
end | end | ||