Module:HeroData: Difference between revisionsGive feedback
Jump to navigation
Jump to search
m Infobox_hero > User:Sur; template vars to snake case |
m calling lang module |
||
| Line 88: | Line 88: | ||
local infobox_attributes = { | local infobox_attributes = { | ||
Weapon = {"DPS", "ClipSize", "RoundsPerSecond", "ReloadTime"}, | Weapon = {"DPS", "ClipSize", "RoundsPerSecond", "ReloadTime"}, | ||
Vitality = {"MaxHealth", "BulletResist", "SpiritResist", " | Vitality = {"MaxHealth", "BulletResist", "SpiritResist", "MaxMoveSpeed"} | ||
} | } | ||
| Line 103: | Line 103: | ||
-- Iterate attribute categories | -- Iterate attribute categories | ||
for | for category, stats in pairs(infobox_attributes) do | ||
stats = attributes_data[category] | |||
-- Iterate stats | |||
for _, stat_name in ipairs(stats) do | |||
stat_data = attributes_data[category][stat_name] | |||
if (stat_data == nil) then return "Attribute in infobox_attributes is not in Data:AttributeData" end | |||
-- gets the stat's value | |||
stat_value = hero_data[stat_name] | |||
if (stat_value == nil) then | |||
stat_value = 0 --default to 0 if not present | |||
end | |||
--Round value to 3 significant figures | |||
stat_value = util_module.round_to_sig_fig(stat_value, 3) | |||
-- get label and postfix | |||
label = lang_module._get_string(stat_data["label"]) | |||
postfix = stat_data["postfix"] | |||
if (postfix == nil) then | |||
postfix = "" | |||
else | |||
postfix = lang_module._get_string(postfix) | |||
end | end | ||
template_args[stat_name] = stat_value .. postfix | |||
end | end | ||
| Line 195: | Line 190: | ||
-- get label and postfix | -- get label and postfix | ||
label = | label = lang_module._get_string(stat_data["label"]) | ||
postfix = stat_data["postfix"] | postfix = stat_data["postfix"] | ||
if (postfix == nil) then | if (postfix == nil) then | ||
postfix = "" | postfix = "" | ||
else | else | ||
postfix = | postfix = lang_module._get_string(postfix) | ||
end | end | ||