Editing Module:ItemTablesGive 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 1: | Line 1: | ||
local p = {}; | local p = {}; | ||
local data = mw.loadJsonData("Data:ItemData.json") | |||
local get_cost = require("Module:ItemData")._get_cost | local get_cost = require("Module:ItemData")._get_cost | ||
local get_type = require("Module:ItemData")._get_type | local get_type = require("Module:ItemData")._get_type | ||
local commas = require("Module:Addcommas") | local commas = require("Module:Addcommas") | ||
local | |||
--- Copies original table with its children as deep as possible. Does not handle metatables. (Copy is needed because Lua passes by reference, not value) | |||
-- @function Deepcopy | |||
-- @param {n-D table} | |||
-- @return {n-D table} | |||
function Deepcopy(orig) | |||
local orig_type = type(orig) | |||
local copy | |||
if orig_type == 'table' then | |||
copy = {} | |||
for orig_key, orig_value in next, orig, nil do | |||
copy[Deepcopy(orig_key)] = Deepcopy(orig_value) | |||
end | |||
else | |||
copy = orig | |||
end | |||
return copy | |||
end | |||
-- Translate internal attribute names to plain text for module calls | -- Translate internal attribute names to plain text for module calls | ||
| Line 24: | Line 42: | ||
friendly_to_internal["out of combat health regen"] = { "OutOfCombatHealthRegen" } | friendly_to_internal["out of combat health regen"] = { "OutOfCombatHealthRegen" } | ||
friendly_to_internal["max health regen"] = { "HealLifePercentOutOfCombat" } | friendly_to_internal["max health regen"] = { "HealLifePercentOutOfCombat" } | ||
friendly_to_internal["fire rate"] = { "BonusFireRate", "FireRateWhenShielded", "FireRateBonus", "FervorFireRate", "AmbushBonusFireRate", "ActiveBonusFireRate | friendly_to_internal["fire rate"] = { "BonusFireRate", "FireRateWhenShielded", "FireRateBonus", "FervorFireRate", "AmbushBonusFireRate", "ActiveBonusFireRate" } | ||
friendly_to_internal["fire rate slow"] = { "FireRateSlow" } | friendly_to_internal["fire rate slow"] = { "FireRateSlow" } | ||
friendly_to_internal["bullet velocity"] = { "BonusBulletSpeedPercent" } | friendly_to_internal["bullet velocity"] = { "BonusBulletSpeedPercent" } | ||
| Line 64: | Line 82: | ||
["Improved Spirit"] = { BonusSprintSpeed = "0"}, | ["Improved Spirit"] = { BonusSprintSpeed = "0"}, | ||
} | } | ||
-- Helper to resolve a stat value, applying any dead‑stat override if defined. | -- Helper to resolve a stat value, applying any dead‑stat override if defined. | ||
| Line 108: | Line 108: | ||
"BaseAttackDamagePercent", "CloseRangeBonusWeaponPower", "LongRangeBonusWeaponPower", "AttackDamageWhenShielded", | "BaseAttackDamagePercent", "CloseRangeBonusWeaponPower", "LongRangeBonusWeaponPower", "AttackDamageWhenShielded", | ||
"TechResist", "BulletResist", | "TechResist", "BulletResist", | ||
"BonusFireRate", "FireRateWhenShielded", "FervorFireRate", "FireRateBonus", "AmbushBonusFireRate", "ActiveBonusFireRate | "BonusFireRate", "FireRateWhenShielded", "FervorFireRate", "FireRateBonus", "AmbushBonusFireRate", "ActiveBonusFireRate", "FireRateSlow", | ||
"LocalBulletArmorReduction", "ReturnFireBulletResist", "BulletArmorReduction", "BulletResistReduction", "BulletResistPerStack", | "LocalBulletArmorReduction", "ReturnFireBulletResist", "BulletArmorReduction", "BulletResistReduction", "BulletResistPerStack", | ||
"TechArmorDamageReduction", "MagicResistReduction", | "TechArmorDamageReduction", "MagicResistReduction", | ||
| Line 198: | Line 198: | ||
listofKeysTable = friendlyNames(property) | listofKeysTable = friendlyNames(property) | ||
local filteredData = | local filteredData = {} | ||
for _, v in pairs(data) do | |||
for _, t in ipairs(listofKeysTable) do | |||
local statValue = resolveStatValue(v, t) | |||
if statValue ~= nil and v["IsDisabled"] == false and v["Name"] ~= nil and statValue ~= "0" and statValue ~= "0m" and statValue ~= "" then | |||
table.insert(filteredData, v) | |||
break | |||
end | |||
end | |||
end | |||
table.sort(filteredData, defaultSort()) | table.sort(filteredData, defaultSort()) | ||