Module:ItemData/nav: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Tag: Undo |
m write_item_slot_subgroup initial |
||
| Line 2: | Line 2: | ||
local items_data = mw.loadJsonData("Data:ItemData.json") | local items_data = mw.loadJsonData("Data:ItemData.json") | ||
local lang_module = require('Module:Lang') | local lang_module = require('Module:Lang') | ||
local generic_module = require('Module:GenericData') | |||
--With debug_mode on, it outputs unprocessed wikitext | --With debug_mode on, it outputs unprocessed wikitext | ||
| Line 76: | Line 77: | ||
-- for [[Template:Infobox ShopItems]] | -- for [[Template:Infobox ShopItems]] | ||
function p.get_item_nav_cards( | function p.get_item_nav_cards(slot, min_souls, max_souls, debug_mode) | ||
-- If called internally (direct Lua call), args will be passed directly. | |||
-- If called from wikitext, `slot` will be the `frame` object, and we get args from `frame.args`. | |||
-- Handle the case where it's called via #invoke (i.e., from wikitext) | |||
if type(slot) == "table" and slot.args then | |||
local frame = slot | |||
slot = frame.args[1] | |||
debug_mode = frame.args["debug_mode"] | |||
end | |||
local left_wrap = '{{ItemBox|item_name=' | local left_wrap = '{{ItemBox|item_name=' | ||
local right_wrap = '}}' | local right_wrap = '}}' | ||
| Line 88: | Line 95: | ||
return process_debug_mode(item_list, debug_mode) | return process_debug_mode(item_list, debug_mode) | ||
end | |||
function p.write_item_slot_subgroup(frame) | |||
local slot = frame.args[1] | |||
local debug_mode = frame.args['debug_mode'] | |||
if slot == nil then return "'slot' parameter is required" end | |||
local ret = '' | |||
local prices = generic_module.get_item_price_per_tier() | |||
for i, souls in ipairs(prices) do | |||
--Determine lower and upper bound for soul | |||
min_souls = souls | |||
max_souls = prices[i+1] | |||
if max_souls == nil then | |||
max_souls = min_souls * 10 --essentially have no upper bound | |||
end | |||
ret = ret .. "|group" .. i .. "={{Souls|500|Shadow=here}}" | |||
ret = ret .. "|list" .. i .. "=" .. p.get_item_nav_cards(slot, min_souls, max_souls) | |||
end | |||
return process_debug_mode(ret, debug_mode) | |||
end | end | ||
return p | return p | ||