Editing Module:Infobox itemGive 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 15: | Line 15: | ||
local tostring = tostring | local tostring = tostring | ||
local type = type | local type = type | ||
-- Pre-computed constants | -- Pre-computed constants | ||
local STATUS_FMT = "[[{{#invoke:Lang|get_string|Citadel_%s}}]]" | local STATUS_FMT = "[[{{#invoke:Lang|get_string|Citadel_%s}}]]" | ||
.. " [[{{#invoke:Lang|get_string|Citadel_StatusEffect}}]]" | .. " [[{{#invoke:Lang|get_string|Citadel_StatusEffect}}]]" | ||
-- Label key remapping table (replaces if/elseif chain) | -- Label key remapping table (replaces if/elseif chain) | ||
local LABEL_KEY_REMAP = { | local LABEL_KEY_REMAP = { | ||
BuildUpPerShot = "BuildupPerShot", | |||
DotDuration = "DOTDuration", | DotDuration = "DOTDuration", | ||
} | } | ||
| Line 69: | Line 50: | ||
local conditional_label -- lazily initialised | local conditional_label -- lazily initialised | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
| Line 117: | Line 68: | ||
local function get_json_item(name) | local function get_json_item(name) | ||
local direct = data[name] | |||
local direct = data[ | |||
if direct and not direct.IsDisabled then return direct end | if direct and not direct.IsDisabled then return direct end | ||
local fallback | local fallback | ||
for _, v in pairs(data) do | for _, v in pairs(data) do | ||
if v.Name == | if v.Name == name then | ||
if not v.IsDisabled then return v end | if not v.IsDisabled then return v end | ||
fallback = fallback or v | fallback = fallback or v | ||
| Line 177: | Line 125: | ||
local function get_component_of_sorted(item_input) | local function get_component_of_sorted(item_input) | ||
local target_key | local target_key | ||
if data[ | if data[item_input] then | ||
target_key = | target_key = item_input | ||
else | else | ||
for k, v in pairs(data) do | for k, v in pairs(data) do | ||
if v.Name == | if v.Name == item_input and not v.IsDisabled then | ||
target_key = k | target_key = k | ||
break | break | ||
| Line 236: | Line 181: | ||
if label == "" then return val_str end | if label == "" then return val_str end | ||
-- Resolve link priority: Override > JSON Stat | -- Resolve link priority: Override > Attribute Map Link > JSON Stat Link | ||
local link_target = link_override | local link_target = link_override | ||
if not link_target or link_target == "" then | if not link_target or link_target == "" then | ||
link_target = | link_target = attr_link | ||
end | end | ||
if not link_target or link_target == "" then | if not link_target or link_target == "" then | ||
link_target = | link_target = stat_links[prop_key] | ||
end | end | ||
| Line 271: | Line 216: | ||
if not conditional_label then | if not conditional_label then | ||
conditional_label = format( | conditional_label = format( | ||
'<span style="color:#C0C0C0">%s</span>', | '<span style="color:#C0C0C0">(%s)</span>', | ||
lang.get_string("Citadel_Shop_ConditionalAttribute") | lang.get_string("Citadel_Shop_ConditionalAttribute") | ||
) | ) | ||
| Line 302: | Line 247: | ||
local icon_str | local icon_str | ||
if size and size ~= "" then | if size and size ~= "" then | ||
icon_str = format("{{Icon/%s|[[File:%s|%spx|link=%s | icon_str = format("{{Icon/%s|[[File:%s|%spx]]|link=%s}}", color, img, size, link or "") | ||
else | else | ||
icon_str = format("{{Icon/%s|[[File:%s|%spx|link=%s | icon_str = format("{{Icon/%s|[[File:%s|%spx]]|link=%s}}", color, img, 20, link or "") | ||
end | end | ||
return { | return { | ||
| Line 455: | Line 376: | ||
return append_conditional(val_str, allow_conditional, usage_flags) | return append_conditional(val_str, allow_conditional, usage_flags) | ||
end | end | ||
| Line 499: | Line 403: | ||
for _, prop_obj in ipairs(prop_list or {}) do | for _, prop_obj in ipairs(prop_list or {}) do | ||
local key = prop_obj.Key | local key = prop_obj.Key | ||
if not seen | if not seen[key] and ( | ||
key:match("^StatusEffect") | key:match("^StatusEffect") | ||
or is_property_in_lang_data(key, prop_obj.LocTokenOverride) | or is_property_in_lang_data(key, prop_obj.LocTokenOverride) | ||
| Line 520: | Line 424: | ||
local item_name = frame.args[1] | local item_name = frame.args[1] | ||
if not item_name then return "Item name missing" end | if not item_name then return "Item name missing" end | ||
local item = get_json_item(item_name) | local item = get_json_item(item_name) | ||
| Line 528: | Line 429: | ||
local ItemData = require("Module:ItemData") | local ItemData = require("Module:ItemData") | ||
local lines = { "{{Infobox item" } | local lines = { "{{Monster_Domosed/Infobox item" } | ||
if enhanced then | if enhanced then | ||
insert(lines, "| enhanced = true") | insert(lines, "| enhanced = true") | ||
end | end | ||
insert(lines, "| item_name = " .. item_name) | |||
insert(lines, "| item_name = " .. | |||
if item.StreetBrawl == true then | if item.StreetBrawl == true then | ||
insert(lines, "| street_brawl = true") | insert(lines, "| street_brawl = true") | ||
end | end | ||
| Line 555: | Line 449: | ||
if section.Type == "Innate" then | if section.Type == "Innate" then | ||
for _, obj in ipairs(section.Main or {}) do | for _, obj in ipairs(section.Main or {}) do | ||
if | if is_property_in_lang_data(obj.Key, obj.LocTokenOverride) then | ||
local val | local val | ||
if enhanced then | if enhanced then | ||
val = format_value_enhanced( | val = format_value_enhanced( | ||
item_name, obj.Key, obj.Value, obj.Type, | |||
obj.LocTokenOverride, nil, false, obj.UsageFlags, | obj.LocTokenOverride, nil, false, obj.UsageFlags, | ||
true -- disable_attr | true -- disable_attr | ||
| Line 577: | Line 471: | ||
end | end | ||
for _, obj in ipairs(section.Alt or {}) do | for _, obj in ipairs(section.Alt or {}) do | ||
if | if is_property_in_lang_data(obj.Key, obj.LocTokenOverride) then | ||
local val | local val | ||
if enhanced then | if enhanced then | ||
val = format_value_enhanced( | val = format_value_enhanced( | ||
item_name, obj.Key, obj.Value, obj.Type, | |||
obj.LocTokenOverride, nil, false, obj.UsageFlags, | obj.LocTokenOverride, nil, false, obj.UsageFlags, | ||
true -- disable_attr | true -- disable_attr | ||
| Line 602: | Line 496: | ||
------------------------------------------------------------------ | ------------------------------------------------------------------ | ||
-- Build formatters once (closures capture | -- Build formatters once (closures capture item_name) | ||
------------------------------------------------------------------ | ------------------------------------------------------------------ | ||
local main_formatter, alt_formatter | local main_formatter, alt_formatter | ||
| Line 609: | Line 503: | ||
main_formatter = function(obj) | main_formatter = function(obj) | ||
if obj.Key:match("^StatusEffect") then | if obj.Key:match("^StatusEffect") then | ||
return | return format(STATUS_FMT, obj.Key) | ||
end | end | ||
return format_value_enhanced( | return format_value_enhanced( | ||
item_name, obj.Key, obj.Value, obj.Type, | |||
obj.LocTokenOverride, false, true, obj.UsageFlags, nil, true | obj.LocTokenOverride, false, true, obj.UsageFlags, nil, true | ||
) | ) | ||
end | end | ||
alt_formatter = function(obj) | alt_formatter = function(obj) | ||
return format_value_enhanced( | return format_value_enhanced( | ||
item_name, obj.Key, obj.Value, obj.Type, | |||
obj.LocTokenOverride, nil, false, obj.UsageFlags, | obj.LocTokenOverride, nil, false, obj.UsageFlags, | ||
true -- disable_attr | true -- disable_attr | ||
| Line 629: | Line 520: | ||
main_formatter = function(obj) | main_formatter = function(obj) | ||
if obj.Key:match("^StatusEffect") then | if obj.Key:match("^StatusEffect") then | ||
return | return format(STATUS_FMT, obj.Key) | ||
end | end | ||
return format_value( | return format_value( | ||
| Line 637: | Line 528: | ||
end | end | ||
alt_formatter = function(obj) | alt_formatter = function(obj) | ||
return format_value( | return format_value( | ||
obj.Key, obj.Value, obj.Type, obj.LocTokenOverride, | obj.Key, obj.Value, obj.Type, obj.LocTokenOverride, | ||
| Line 667: | Line 555: | ||
insert(lines, format( | insert(lines, format( | ||
"| %s%d_description = {{#invoke:Lang|get_string|%s|item_name=%s}}", | "| %s%d_description = {{#invoke:Lang|get_string|%s|item_name=%s}}", | ||
prefix, counter, loc, | prefix, counter, loc, item_name | ||
)) | )) | ||
end | end | ||
| Line 678: | Line 566: | ||
for _, prop_obj in ipairs(section.Main or {}) do | for _, prop_obj in ipairs(section.Main or {}) do | ||
local key = prop_obj.Key | local key = prop_obj.Key | ||
if not main_seen | if not main_seen[key] and ( | ||
key:match("^StatusEffect") | key:match("^StatusEffect") | ||
or is_property_in_lang_data(key, prop_obj.LocTokenOverride) | or is_property_in_lang_data(key, prop_obj.LocTokenOverride) | ||
| Line 698: | Line 586: | ||
local key = prop_obj.Key | local key = prop_obj.Key | ||
-- Skip keys already emitted as main stats | -- Skip keys already emitted as main stats | ||
if not main_seen[key] and not alt_seen | if not main_seen[key] and not alt_seen[key] and ( | ||
key:match("^StatusEffect") | key:match("^StatusEffect") | ||
or is_property_in_lang_data(key, prop_obj.LocTokenOverride) | or is_property_in_lang_data(key, prop_obj.LocTokenOverride) | ||
| Line 712: | Line 600: | ||
-- Cooldown / ChargeUp | -- Cooldown / ChargeUp | ||
local cd = format_section_cooldown(section, | local cd = format_section_cooldown(section, item_name, enhanced) | ||
if cd.cooldown then | if cd.cooldown then | ||
insert(lines, format("| %s%d_cooldown = %s", prefix, counter, cd.cooldown)) | insert(lines, format("| %s%d_cooldown = %s", prefix, counter, cd.cooldown)) | ||
| Line 732: | Line 620: | ||
------------------------------------------------------------------ | ------------------------------------------------------------------ | ||
for i = 1, 2 do | for i = 1, 2 do | ||
local comp = ItemData.get_component_name { args = { | local comp = ItemData.get_component_name { args = { item_name, i } } | ||
if comp and comp ~= "" then | if comp and comp ~= "" then | ||
insert(lines, format("| component%d_name = %s", i, comp)) | insert(lines, format("| component%d_name = %s", i, comp)) | ||