Module:HeroData: Difference between revisionsGive feedback
Jump to navigation
Jump to search
m create_stat_boxes moved to hero.write_stat_boxes |
m category data moved to attribute data; utils_module>util_module; attributes_module>attribute_module |
||
| Line 2: | Line 2: | ||
local heroes_data = mw.loadJsonData("Data:HeroData.json") | local heroes_data = mw.loadJsonData("Data:HeroData.json") | ||
local attributes_data = mw.loadJsonData("Data:AttributeData.json") | local attributes_data = mw.loadJsonData("Data:AttributeData.json") | ||
local | local util_module = require('Module:Utilities') | ||
local attribute_module = require('Module:AttributeData') | |||
-- returns the table of a specific item, used by external modules | -- returns the table of a specific item, used by external modules | ||
| Line 57: | Line 58: | ||
--If the stat scales | --If the stat scales | ||
if (scaling_value ~= nil) then | if (scaling_value ~= nil) then | ||
scaling_value = | scaling_value = util_module.round_to_sig_fig(scaling_value, 3) | ||
--The hero has a scaling value with this stat | --The hero has a scaling value with this stat | ||
| Line 124: | Line 125: | ||
local stats_to_add_blank_after = {BulletLifesteal = true, CritDamageReceivedScale = true} | local stats_to_add_blank_after = {BulletLifesteal = true, CritDamageReceivedScale = true} | ||
if (hero_data == nil) then return "Hero Not Found in AttrData" end | if (hero_data == nil) then return "Hero Not Found in AttrData" end | ||
local category_data = | local category_data = attribute_module.get_category_data() | ||
for _, category in ipairs(attributes_data["_category_order"]) do | for _, category in ipairs(attributes_data["_category_order"]) do | ||
stats = attributes_data[category] | stats = attributes_data[category] | ||
local category_values = category_data[category] | local category_values = category_data[category] | ||
template_args["box_name"] = category_values. | template_args["box_name"] = category_values.unlocalized_name | ||
template_args["box_rgb"] = category_values. | template_args["box_rgb"] = category_values.rgb | ||
template_args["num_cols"] = | template_args["num_cols"] = 2 | ||
cell_values = "" | cell_values = "" | ||
| Line 165: | Line 150: | ||
--Round value to 3 significant figures | --Round value to 3 significant figures | ||
stat_value = | stat_value = util_module.round_to_sig_fig(stat_value, 3) | ||
-- get label and postfix | -- get label and postfix | ||
label = | label = util_module.call_lang(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 = util_module.call_lang(postfix) | ||
end | end | ||
-- Check if icon file exists, and if not, don't use any image | -- Check if icon file exists, and if not, don't use any image | ||
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png' | image_file_name = 'File:AttributeIcon' .. stat_name .. '.png' | ||
image_file_name = | image_file_name = util_module.get_image_file(image_file_name) | ||
-- Add an empty cell following some stats to align them correctly as seen in game | -- Add an empty cell following some stats to align them correctly as seen in game | ||