Module:Sandbox/LVL: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 236: | Line 236: | ||
end | end | ||
-- | -------------------------------------------------------------------- | ||
local function write_disabled_item_list(slot, template, sep) | -- 1. Builds the wikitext for ONE price bracket | ||
-------------------------------------------------------------------- | |||
local function write_disabled_item_list(slot, min_souls, max_souls, template, sep) | |||
local t = {} | local t = {} | ||
for k,d in pairs(items_data) do | for k, d in pairs(items_data) do | ||
if d.Name and d.IsDisabled==true and (slot=="" or d.Slot==slot) then | local cost = tonumber(d.Cost) | ||
local en = lang_module.get_string(k,"en") | if d.Name | ||
local lc = lang_module.get_lang_code() | and d.IsDisabled == true | ||
local loc= lang_module.get_string(k,lc) | and cost | ||
and (slot == "" or d.Slot == slot) | |||
and cost >= min_souls | |||
and cost < max_souls | |||
then | |||
local en = lang_module.get_string(k, "en") | |||
local lc = lang_module.get_lang_code() | |||
local loc = lang_module.get_string(k, lc) | |||
local piece | local piece | ||
if template=="ItemBox" then | if template == "ItemBox" then | ||
piece = lc=="en" | piece = (lc == "en") | ||
and "{{ItemBox|item_name= | and string.format("{{ItemBox|item_name=%s}}", en) | ||
or "{{ItemBox|item_name= | or string.format("{{ItemBox|item_name=%s|item_loc=%s|link=%s/%s}}", | ||
else --ItemIcon | en, loc, en, lc) | ||
piece = lc=="en" | else -- default to ItemIcon | ||
and "{{ItemIcon| | piece = (lc == "en") | ||
or "{{ItemIcon| | and string.format("{{ItemIcon|%s}}", en) | ||
or string.format("{{ItemIcon|%s|lang=%s|%s}}", en, lc, loc) | |||
end | end | ||
table.insert(t, piece) | table.insert(t, piece) | ||
| Line 262: | Line 272: | ||
end | end | ||
-- | -------------------------------------------------------------------- | ||
-- 2. Entry point that mimics write_item_slot_subgroup for disabled items | |||
-------------------------------------------------------------------- | |||
function p.write_disabled_subgroup(frame) | function p.write_disabled_subgroup(frame) | ||
local slot = frame.args[1] or "" -- Weapon/Armor/Tech/ | local slot = frame.args[1] or "" -- Weapon / Armor / Tech / "" | ||
local template = frame.args[2] or "ItemBox" | local template = frame.args[2] or "ItemBox" | ||
local sep = frame.args.sep or " " | local sep = frame.args.sep or " " | ||
local debug_mode = frame.args.debug_mode | local debug_mode = frame.args.debug_mode | ||
local prices = generic_module.get_item_price_per_tier() | local prices = generic_module.get_item_price_per_tier() | ||
local soul_style = "font-size: 12px; text-shadow: 1px 1px rgba(0,0,0,0.3);" | local soul_style = "font-size: 12px; text-shadow: 1px 1px rgba(0,0,0,0.3);" | ||
local args = { | local args = { | ||
groupstyle = "background-color:"..util_module.get_slot_color(slot).. | groupstyle = "background-color:" .. util_module.get_slot_color(slot) .. | ||
";width:10%;min-width:70px;border-radius:8px 0 0 8px", | |||
grouppadding = "5px", | grouppadding = "5px", | ||
listpadding = "0 0.25rem", | listpadding = "0 0.25rem", | ||
| Line 279: | Line 292: | ||
local idx = 0 | local idx = 0 | ||
for i,souls in ipairs(prices) do | for i, souls in ipairs(prices) do | ||
if souls ~= 0 then | if souls ~= 0 then -- skip 0-500 bracket | ||
local max = prices[i+1] or souls*10 | local max = prices[i + 1] or souls * 10 | ||
args["group"..idx] = | args["group" .. idx] = | ||
frame:expandTemplate{title="Souls", args={[1]=souls,Shadow=soul_style}} | frame:expandTemplate{title = "Souls", | ||
args["list"..idx] | args = {[1] = souls, Shadow = soul_style}} | ||
write_disabled_item_list(slot, template, sep) | args["list" .. idx] = | ||
write_disabled_item_list(slot, min_souls, max_souls, template, sep) | |||
idx = idx + 1 | idx = idx + 1 | ||
end | end | ||
end | end | ||
local out = frame:expandTemplate{title="Navbox subgroup", args=args} | local out = frame:expandTemplate{title = "Navbox subgroup", args = args} | ||
return process_debug_mode(out, debug_mode) | return process_debug_mode(out, debug_mode) | ||
end | end | ||
return p | return p | ||