Module:ItemTables: Difference between revisionsGive feedback
cap first letter, fix spacing |
add more keys, add unit suffix |
||
| Line 55: | Line 55: | ||
-- end | -- end | ||
local | local friendly_to_internal = {} | ||
friendly_to_internal["ammo"] = { "BonusClipSizePercent", "BonusClipSize" } | |||
friendly_to_internal["weapon damage"] = { "BaseAttackDamagePercent" } | |||
friendly_to_internal["bullet shield health"] = { "BulletShieldMaxHealth", "BulletShieldOnCast", "SaviorBulletShieldHealth", "FlyingBulletShield" } | |||
friendly_to_internal["spirit shield health"] = { "TechShieldMaxHealth", "TechShieldOnCast", "SaviorMagicShieldHealth", "FlyingTechShield" } | |||
friendly_to_internal["spirit resist"] = { "TechResist" } | |||
friendly_to_internal["bullet resist"] = { "BulletResist" } | |||
friendly_to_internal["health"] = { "BonusHealth" } | |||
friendly_to_internal["health regen"] = { "BonusHealthRegen" } | |||
friendly_to_internal["fire rate"] = { "BonusFireRate" } | |||
friendly_to_internal["stamina"] = { "Stamina" } | |||
friendly_to_internal["stamina recovery"] = { "StaminaCooldownReduction" } | |||
function | local function friendlyNames(desc) | ||
local keysTable = {} | local keysTable = {} | ||
desc = string.lower(desc or "") | desc = string.lower(desc or "") | ||
for link, patterns in pairs( | for link, patterns in pairs(friendly_to_internal) do | ||
if (desc == link) then keysTable = patterns end | if (desc == link) then keysTable = patterns end | ||
end | end | ||
return keysTable | return keysTable | ||
end | end | ||
local unitSuffix = { | |||
["%"] = { "BonusClipSizePercent", "BaseAttackDamagePercent", "TechResist", "BulletResist", "BonusFireRate", "StaminaCooldownReduction" }, | |||
["m/s"] = { "BonusMoveSpeed" } | |||
} | |||
local function appendSuffix(internal) | |||
local unitName = "" | |||
for key, s in pairs(unitSuffix) do | |||
for link, pattern in pairs(s) do | |||
if (internal == pattern) then return key end | |||
end | |||
end | |||
return unitName | |||
end | |||
p.itemPropTable = function(frame) | p.itemPropTable = function(frame) | ||
| Line 81: | Line 100: | ||
local property = frame.args[1] or mw.title.getCurrentTitle().text | local property = frame.args[1] or mw.title.getCurrentTitle().text | ||
local copyVar = property | local copyVar = property | ||
listofKeysTable = | listofKeysTable = friendlyNames(property) | ||
local createTable = mw.html.create('table') | local createTable = mw.html.create('table') | ||
| Line 117: | Line 136: | ||
:tag('td'):wikitext(get_cost(itemName["Name"])):done() | :tag('td'):wikitext(get_cost(itemName["Name"])):done() | ||
:tag('td'):wikitext(get_type(itemName["Name"])):done() | :tag('td'):wikitext(get_type(itemName["Name"])):done() | ||
:tag('td'):wikitext("+<b>" .. itemName[t].. "</b> " .. copyVar):done() | :tag('td'):wikitext("+<b>" .. itemName[t].. "</b>" .. appendSuffix(t) .. " " .. copyVar):done() | ||
table.insert(requirements, tableData) | table.insert(requirements, tableData) | ||