Module:ItemData/nav: Difference between revisions

Sur (talk | contribs)
m reverting failed attempt- Undo revision 13674 by Sur (talk)
Tag: Undo
Sur (talk | contribs)
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(frame)
function p.get_item_nav_cards(slot, min_souls, max_souls, debug_mode)
local slot = frame.args[1]
-- If called internally (direct Lua call), args will be passed directly.
local min_souls = frame.args[2]
    -- If called from wikitext, `slot` will be the `frame` object, and we get args from `frame.args`.
local max_souls = frame.args[3]
 
local debug_mode = frame.args["debug_mode"]
    -- 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