Module:Sandbox/LVL: Difference between revisionsGive feedback
No edit summary |
No edit summary |
||
| Line 11: | Line 11: | ||
local success, lang_data = pcall(mw.loadJsonData, lang_file_name) | local success, lang_data = pcall(mw.loadJsonData, lang_file_name) | ||
if not success then lang_data = {} end | if not success then lang_data = {} end | ||
-- Keys to explicitly ignore (metadata, not stats) | |||
local ignore_keys = { | |||
["Name"] = true, ["Description"] = true, ["Cost"] = true, ["Tier"] = true, | |||
["Activation"] = true, ["Slot"] = true, ["Components"] = true, ["TargetTypes"] = true, | |||
["ShopFilters"] = true, ["IsDisabled"] = true, ["StreetBrawl"] = true, ["IsImbue"] = true, | |||
["AbilityUnitTargetLimit"] = true, ["AbilityCooldownBetweenCharge"] = true, | |||
["ChannelMoveSpeed"] = true, ["NPCDamageMult"] = true, ["DamageHeight"] = true, | |||
["Scale"] = true, ["Value"] = true -- Internal sub-table keys we don't need as text | |||
} | |||
local terms = {} | local terms = {} | ||
| Line 16: | Line 26: | ||
if type(tbl) ~= "table" then return end | if type(tbl) ~= "table" then return end | ||
for k, v in pairs(tbl) do | for k, v in pairs(tbl) do | ||
-- Only process string keys | -- Only process string keys that aren't in our ignore list | ||
if type(k) == "string" then | if type(k) == "string" and not ignore_keys[k] then | ||
-- | -- Try to get the in-game name from the lang file | ||
local term = lang_data[k .. "_label"] or lang_data[k] | local term = lang_data[k .. "_label"] or lang_data[k] | ||
if term and type(term) == "string" then | if term and type(term) == "string" then | ||
| Line 26: | Line 36: | ||
table.insert(terms, string.lower(term)) | table.insert(terms, string.lower(term)) | ||
else | else | ||
-- Fallback: Convert CamelCase to spaces (e.g., | -- Fallback: Convert CamelCase to spaces (e.g., BonusMoveSpeed -> bonus move speed) | ||
local fallback_term = string.lower(k:gsub("(%u)", " %1"):gsub("^%s", "")) | local fallback_term = string.lower(k:gsub("(%u)", " %1"):gsub("^%s", "")) | ||
table.insert(terms, fallback_term) | table.insert(terms, fallback_term) | ||
| Line 34: | Line 44: | ||
if type(v) == "table" then | if type(v) == "table" then | ||
recurse(v) | recurse(v) | ||
-- Notice: We completely ignore string values here, which drops descriptions! | |||
-- We also ignore numbers and booleans. We only want the stat names (keys). | |||
end | end | ||
end | end | ||