Module:Inventory

Documentation for this module may be created at Module:Inventory/doc

p = {}
-- invName = mw.getCurrentFrame().args[1]
invItm = mw.getCurrentFrame().args[1]
invArm = mw.getCurrentFrame().args[2]
invWpn = mw.getCurrentFrame().args[3]
invMark = mw.getCurrentFrame().args[4]
invFunc = mw.getCurrentFrame().args[5]

function p.makeList()
    txtout = ''
    if (invItm ~= nil) then
        Items = mw.text.split(invItm,';',true)
        for k, itm in ipairs(Items) do
            if (txtout == '') then
                txtout = string.format('[[%s]]', itm)
            else
                txtout = string.format('%s; [[%s]]', txtout, itm)
            end
        end
    end
    if (invArm ~= nil) then
        Items = mw.text.split(invArm,';',true)
        for k, itm in ipairs(Items) do
            if (txtout == '') then
                txtout = string.format('[[%s]]', itm)
            else
                txtout = string.format('%s; [[%s]]', txtout, itm)
            end
        end
    end
    if (invWpn ~= nil) then
        Items = mw.text.split(invWpn,';',true)
        for k, itm in ipairs(Items) do
            if (txtout == '') then
                txtout = string.format('[[%s]]', itm)
            else
                txtout = string.format('%s; [[%s]]', txtout, itm)
            end
        end
    end
    return txtout
end

function p.getItems()
    itmtxt = ''
    if invMark == nil then
        invMark = 1
    end
    if (invItm ~= nil and invItm ~= '') then
        Items = mw.text.split(invItm,';',true)
        argtbl = { 'ItmCityTblx', string.format('Markup=%s',invMark)}
        for k, itm in ipairs(Items) do
            inm = string.format(':%s',itm)
            itmtxt = itmtxt .. mw.getCurrentFrame():expandTemplate{ title = inm, args = argtbl }
        end
    end
    if (invArm ~= nil and invArm ~= '') then
        Items = mw.text.split(invArm,';',true)
        argtbl = { 'ArmCityTblx', string.format('Markup=%s',invMark)}
        for k, itm in ipairs(Items) do
            inm = string.format(':%s',itm)
            itmtxt = itmtxt .. mw.getCurrentFrame():expandTemplate{ title = inm, args = argtbl }
        end
    end
    if (invWpn ~= nil and invWpn ~= '') then
        Items = mw.text.split(invWpn,';',true)
        argtbl = { 'WpnCityTblx', string.format('Markup=%s',invMark)}
        for k, itm in ipairs(Items) do
            inm = string.format(':%s',itm)
            itmtxt = itmtxt .. mw.getCurrentFrame():expandTemplate{ title = inm, args = argtbl }
        end
    end
    return itmtxt
end
return p