Module:GameData: Difference between revisions

Vergir (talk | contribs)
Create GameData module for generic cross-dataset entity filtering (with help from vergir-bot LLM)
 
Remove Upgrades skip in find_value so abilities gaining charges via upgrades are included (with help from vergir-bot LLM)
Line 25: Line 25:
end
end


-- Recursively searches a record for a given key at any nesting level.
-- Recursively searches a record for a given key at any nesting level,
-- Deliberately skips the "Upgrades" array, which contains delta values
-- including inside the Upgrades array. This means abilities or items that
-- rather than base stats and should not be matched against.
-- only gain a property via an upgrade tier will still be matched.
-- @param  record  table  the data record to search
-- @param  record  table  the data record to search
-- @param  key    string  the internal property name to look for
-- @param  key    string  the internal property name to look for
Line 33: Line 33:
local function find_value(record, key)
local function find_value(record, key)
     for k, v in pairs(record) do
     for k, v in pairs(record) do
         if k == "Upgrades" then
         if k == key then
            -- skip
        elseif k == key then
             return v
             return v
         elseif type(v) == "table" then
         elseif type(v) == "table" then