Module:Abilities: Difference between revisions

Jump to navigation Jump to search
added nesting function for ability upgrades
No edit summary
Line 126: Line 126:
if not ability then
if not ability then
return "Ability Not Found"
return "Ability Not Found"
end
-- Handle nested properties via dot notation (e.g., "MaxRage.Scale.Value")
local element = ability
if prop and prop ~= "" then
for segment in string.gmatch(prop, "[^%.]+") do
if type(element) ~= "table" then
return "" -- Can't traverse further
end
element = element[segment]
if element == nil then return "" end
end
end
end
Line 160: Line 148:
-- Get the desired property from the specific upgrade
-- Get the desired property from the specific upgrade
local element = upgrade[prop]
local element = upgrade[prop]
if prop and prop ~= "" then
for segment in string.gmatch(prop, "[^%.]+") do
if type(element) ~= "table" then
return "" -- Can't traverse further
end
element = element[segment]
if element == nil then return "" end
end
end
if element == nil then
if element == nil then
return "" -- The property doesn't exist in this specific upgrade, which is a valid case. Return empty.
return "" -- The property doesn't exist in this specific upgrade, which is a valid case. Return empty.