Difference between revisions of "Module:Augmenting Uses"

From Idlescape Wiki
Jump to navigation Jump to search
(Added XP column)
(Added Dust and Scrap column)
Line 7: Line 7:
 
local scrappingBaseXp = 20
 
local scrappingBaseXp = 20
 
local scrappingXpPower = 2
 
local scrappingXpPower = 2
 +
  
 
local augmentationBonusNames ={
 
local augmentationBonusNames ={
Line 26: Line 27:
 
     ["toolBoost.fishingReelPower"] = "Reel",
 
     ["toolBoost.fishingReelPower"] = "Reel",
 
     ["offensiveAccuracyAffinityRating.Chaos"] = [[Combat#Offensive Stats|Choas Accuracy]],
 
     ["offensiveAccuracyAffinityRating.Chaos"] = [[Combat#Offensive Stats|Choas Accuracy]],
     ["weaponBonus.strength"] = "[[Combat#Offensive Stats|strength]]",
+
     ["weaponBonus.strength"] = "[[Combat#Offensive Stats|Strength]]",
 
     ["weaponBonus.intellect"] = "[[Combat#Offensive Stats|intellect]]",
 
     ["weaponBonus.intellect"] = "[[Combat#Offensive Stats|intellect]]",
 
     ["weaponBonus.dexterity"] = "[[Combat#Offensive Stats|dexterity]]",
 
     ["weaponBonus.dexterity"] = "[[Combat#Offensive Stats|dexterity]]",
Line 33: Line 34:
 
     ["offensiveCritical.damageMultiplier"] = "[[Combat#Offensive Stats|Crit Mult]]",
 
     ["offensiveCritical.damageMultiplier"] = "[[Combat#Offensive Stats|Crit Mult]]",
 
     ["armorBonus.agility"] = "[[Combat#Defensive Stats|Agility]]",
 
     ["armorBonus.agility"] = "[[Combat#Defensive Stats|Agility]]",
     ["armorBonus.protection"] = "[[Combat#Defensive Stats|Protectino]]",
+
     ["armorBonus.protection"] = "[[Combat#Defensive Stats|Protection]]",
 
     ["armorBonus.stamina"] = "[[Combat#Defensive Stats|Stamina]]",
 
     ["armorBonus.stamina"] = "[[Combat#Defensive Stats|Stamina]]",
 
     ["armorBonus.resistance"] = "[[Combat#Defensive Stats|Resistance]]",
 
     ["armorBonus.resistance"] = "[[Combat#Defensive Stats|Resistance]]",
 
     ["offensiveAccuracyAffinityRating.Range"] = "[[Combat#Offensive Stats|Range Accuracy]]",
 
     ["offensiveAccuracyAffinityRating.Range"] = "[[Combat#Offensive Stats|Range Accuracy]]",
 
     ["offensiveAccuracyAffinityRating.Blunt"] = "[[Combat#Offensive Stats|Blunt Accuracy]]",
 
     ["offensiveAccuracyAffinityRating.Blunt"] = "[[Combat#Offensive Stats|Blunt Accuracy]]",
 +
}
 +
 +
local tierToDust = {
 +
    [1] = "basic",
 +
    [2] = "basic",
 +
    [3] = "unusual",
 +
    [4] = "singular",
 +
    [5] = "prime",
 +
    [6] = "mythical",
 +
    [7] = "mythical",
 +
    [7.5] = "mythical"
 
}
 
}
  
Line 114: Line 126:
 
         return "Module:Items/data out of date"
 
         return "Module:Items/data out of date"
 
     end
 
     end
 +
end
 +
---gets the augments that have the itemId in thier augmenting cost and returns an array of them
 +
---@param itemId number
 +
---@return table
 +
local function getMatchedAugs(itemId)
 +
    local matchedAugs = {}
 +
    for id, data in pairs(craftingAugmentingData) do
 +
        if data.scrapping then
 +
            for costId, _ in pairsByKeys(data.scrapping) do
 +
                if tonumber(costId) == itemId then
 +
                    matchedAugs[id] = data.scrapping
 +
                end
 +
            end
 +
        end
 +
    end
 +
    return matchedAugs
 +
end
 +
---decides the collase state based on the given string
 +
---@param collapse string
 +
---@return string
 +
local function decideCollapseState(collapse)
 +
    if collapse == "collapseable" then
 +
        collapse = " mw-made-collapsible mw-collapsible"
 +
    elseif collapse == "collapsed" then
 +
        collapse = " mw-made-collapsible mw-collapsible mw-collapsed"
 +
    else
 +
        collapse = ""
 +
    end
 +
    return collapse
 +
end
 +
 +
local function getItemDust(tier)
 +
    if tier <= 2 then
 +
        return "Basic Runic Dust"
 +
    elseif tier <= 3 then
 +
        return "Unusual Runic Dust"
 +
    elseif tier <= 4 then
 +
        return "Singular Runic Dust"
 +
    elseif tier <= 5 then
 +
        return "Prime Runic Dust"
 +
    elseif tier > 5 then
 +
        return "Mythical Runic Dust"
 +
    end
 +
end
 +
 +
local function getItemScrap(item)
 +
    if item.rarity == "common" then
 +
        return "Common Gear Scraps"
 +
    elseif item.rarity == "uncommon" then
 +
        return "Uncommon Gear Scraps"
 +
    elseif item.rarity == "rare" then
 +
        return "Rare Gear Scraps"
 +
    elseif item.rarity == "epic" then
 +
        return "Epic Gear Scraps"
 +
    elseif item.rarity == "legendary" then
 +
        return "Legendary Gear Scraps"
 +
    end
 +
end
 +
 +
local function createImgCell(item)
 +
    local imgCell = mw.html.create('td')
 +
    :wikitext(img._img({item.name, '50'}))
 +
    :done()
 +
    return imgCell
 +
end
 +
 +
local function createNameCell(item)
 +
    local nameCell = mw.html.create('td')
 +
    :wikitext("[[" .. item.name .. "]]")
 +
    :done()
 +
    return nameCell
 +
end
 +
 +
local function createXpCell(item)
 +
    local xpCell = mw.html.create('td')
 +
    :css('text-align', 'center')
 +
    :wikitext(tostring(getScrapExperience(item)))
 +
    :done()
 +
    return xpCell
 +
end
 +
 +
local function createAugBonusCell(item)
 +
    local augBonusCell = mw.html.create('td')
 +
    local augBonusS = ""
 +
    if item.equipmentStats.augmentationBonus then
 +
        local augBonusC = tablelength(item.equipmentStats.augmentationBonus)
 +
        for _, augBonus in ipairs(item.equipmentStats.augmentationBonus) do
 +
            augBonusS = augBonusS .. augmentationBonusNames[augBonus.stat] .. " +" .. augBonus.value
 +
            augBonusC = augBonusC - 1
 +
            if augBonusC > 0 then
 +
                augBonusS = augBonusS .. "<br>"
 +
            end
 +
        end
 +
    elseif not item.equipmentStats.augmentationBonus then
 +
        augBonusS = "-"
 +
    end
 +
 +
    augBonusCell
 +
    :css('text-align', 'center')
 +
    :wikitext(augBonusS)
 +
    :done()
 +
 +
    return augBonusCell
 +
end
 +
 +
local function createCostCell(mItemData, item)
 +
    local costCell = mw.html.create('td')
 +
    local augCostC = tablelength(mItemData)
 +
    for costId, costQuantity in pairsByKeys(mItemData) do
 +
        local costItem = getItem(costId)
 +
        if tonumber(costId) == item.id then
 +
            costCell:tag('span'):css('display', 'inline-block')
 +
                :wikitext(tostring(costQuantity) .. " " .. img._img({costItem.name, '25'}))
 +
                :tag('span'):css('font-weight', 'bold')
 +
                    :wikitext(costItem.name)
 +
                :done()
 +
            :done()
 +
            augCostC = augCostC - 1
 +
            if augCostC > 0  then
 +
                costCell:tag('br')
 +
            end
 +
        else
 +
            costCell:tag('span'):css('display', 'inline-block')
 +
                :wikitext(tostring(costQuantity) .. " " .. img._img({costItem.name, '25', word = 1}))
 +
            :done()
 +
            augCostC = augCostC - 1
 +
            if augCostC > 0  then
 +
                costCell:tag('br')
 +
            end
 +
        end
 +
    end
 +
    return costCell
 +
end
 +
 +
local function createDustCell(item)
 +
    local itemTier = getItemTier(item)
 +
    local dustCell = mw.html.create('td')
 +
    :wikitext(img._img({getItemDust(itemTier), '25', word = 1}))
 +
    :done()
 +
    return dustCell
 +
end
 +
 +
local function createScrapCell(item)
 +
    local scrapCell = mw.html.create('td')
 +
    :wikitext(img._img({getItemScrap(item), '25', word = 1}))
 +
    :done()
 +
    return scrapCell
 
end
 
end
  
 
local function genTable(name, collapse)
 
local function genTable(name, collapse)
     local itemI = getItem(findId._findId({name, "item"}))
+
     local item = getItem(findId._findId({name, "item"}))
 
     local collapseS = ""
 
     local collapseS = ""
 
     if collapse == 1 then
 
     if collapse == 1 then
Line 124: Line 283:
 
         collapseS = " mw-made-collapsible mw-collapsible mw-collapsed"
 
         collapseS = " mw-made-collapsible mw-collapsible mw-collapsed"
 
     end
 
     end
     local matchedAugs = {}
+
     local matchedAugs = getMatchedAugs(item.id)
    for itemId, itemData in pairs(craftingAugmentingData) do
 
        if itemData.scrapping then
 
            for costId, _ in pairsByKeys(itemData.scrapping) do
 
                if tonumber(costId) == itemI.id then
 
                    matchedAugs[itemId] = itemData.scrapping
 
                end
 
            end
 
        end
 
    end
 
 
     local t = mw.html.create("table")
 
     local t = mw.html.create("table")
         t:addClass("wikitable sortable jquery-tablesorter" .. collapseS)
+
         :addClass("wikitable sortable jquery-tablesorter" .. collapseS)
 
         :tag('tr')
 
         :tag('tr')
 
             :tag('th')
 
             :tag('th')
Line 143: Line 293:
 
             :tag('th')
 
             :tag('th')
 
                 :wikitext("XP")
 
                 :wikitext("XP")
 +
            :done()
 +
            :tag('th')
 +
                :wikitext("Dust")
 +
            :done()
 +
            :tag('th')
 +
                :wikitext("Scrap")
 
             :done()
 
             :done()
 
             :tag("th")
 
             :tag("th")
                 :wikitext("Aug. Bonus.")
+
                 :wikitext("Aug. Bonus")
 
             :done()
 
             :done()
 
             :tag("th")
 
             :tag("th")
                 :wikitext("Materials")
+
                 :wikitext("Cost")
 
             :done()
 
             :done()
 
         :done()
 
         :done()
     for itemId, itemData in pairs(matchedAugs) do
+
     for mItemId, mItemData in pairs(matchedAugs) do
         local item = getItem(itemId)
+
         local mItem = getItem(mItemId)
         local dTr = t:tag('tr')
+
         t:tag('tr')
             :tag('td')
+
             :node(createImgCell(mItem))
                :wikitext(img._img({item.name, '40'}))
+
            :node(createNameCell(mItem))
             :done()
+
             :node(createXpCell(mItem))
            :tag('td')
+
             :node(createDustCell(mItem))
                :wikitext("[[" .. item.name .. "]]")
+
            :node(createScrapCell(mItem))
             :done()
+
             :node(createAugBonusCell(mItem))
            :tag('td')
+
             :node(createCostCell(mItemData, item))
                :css('text-align', 'center')
 
                :wikitext(tostring(getScrapExperience(item)))
 
             :done()
 
        local augBonusS = ""
 
        if item.equipmentStats.augmentationBonus then
 
            local augBonusC = tablelength(item.equipmentStats.augmentationBonus)
 
            for _, augBonus in ipairs(item.equipmentStats.augmentationBonus) do
 
                augBonusS = augBonusS .. augmentationBonusNames[augBonus.stat] .. " +" .. augBonus.value
 
                augBonusC = augBonusC - 1
 
                if augBonusC > 0 then
 
                    augBonusS = augBonusS .. "<br>"
 
                end
 
            end
 
        elseif not item.equipmentStats.augmentationBonus then
 
             augBonusS = "-"
 
        end
 
        dTr:tag('td')
 
            :css('text-align', 'center')
 
            :wikitext(augBonusS)
 
 
         :done()
 
         :done()
        local costCell = dTr:tag('td')
 
        local augCostC = tablelength(itemData)
 
        for costId, costQuantity in pairs(itemData) do
 
            local costItem = getItem(costId)
 
            if tonumber(costId) == itemI.id then
 
                costCell:tag('span'):css('display', 'inline-block')
 
                    :wikitext(tostring(costQuantity) .. " " .. img._img({costItem.name, '20'}))
 
                    :tag('span'):css('font-weight', 'bold')
 
                        :wikitext(costItem.name)
 
                    :done()
 
                :done()
 
                augCostC = augCostC - 1
 
                if augCostC > 0  then
 
                    costCell:tag('br')
 
                end
 
            else
 
                costCell:tag('span'):css('display', 'inline-block')
 
                    :wikitext(tostring(costQuantity) .. " " .. img._img({costItem.name, '20', word = 1}))
 
                :done()
 
            augCostC = augCostC - 1
 
            if augCostC > 0  then
 
                costCell:tag('br')
 
            end
 
            end
 
        end
 
        dTr:done()
 
 
     end
 
     end
 
     return t
 
     return t
Line 222: Line 333:
 
         name = _args[1]
 
         name = _args[1]
 
     end
 
     end
     local collapse = 0
+
     local t = genTable(name, decideCollapseState(_args["collapse"]))
    if _args["collapse"] == "collapseable" then
 
        collapse = 1
 
    elseif _args["collapse"] == "collapsed" then
 
        collapse =2
 
    end
 
    local t = genTable(name, collapse)
 
 
 
 
     return t
 
     return t
 
end
 
end
 
return p
 
return p

Revision as of 14:52, 3 July 2024


local p = {}
local findId = require("Module:FindId")
local img = require("Module:Img")
local craftingAugmentingData = mw.loadData("Module:CraftingAugmenting/data")
local itemsData = mw.loadData("Module:Items/data")
local pageName = mw.title.getCurrentTitle().fullText
local scrappingBaseXp = 20
local scrappingXpPower = 2


local augmentationBonusNames ={
    ["toolBoost.mining"] = "[[mining]]",
    ["toolBoost.foraging"] = "[[foraging]]",
    ["offensiveAccuracyAffinityRating.Ice"] = "[[Combat#Offensive Stats|Ice Accuracy]]",
    ["offensiveAccuracyAffinityRating.Nature"] = "[[Combat#Offensive Stats|Nature Accuracy]]",
    ["offensiveAccuracyAffinityRating.Fire"] = "[[Combat#Offensive Stats|Fire Accuracy]]",
    ["offensiveAccuracyAffinityRating.Lightning"] = "[[Combat#Offensive Stats|Lightning Accuracy]]",
    ["offensiveAccuracyAffinityRating.Magic"] = "[[Combat#Offensive Stats|Magic Accuracy]]",
    ["toolBoost.farming"] = "[[Farming]]",
    ["toolBoost.smithing"] = "[[Smithing]]",
    ["toolBoost.runecrafting"] = "[[Runecrafting]]",
    ["toolBoost.cooking"] = "[[cooking]]",
    ["toolBoost.enchanting"] = "[[enchanting]]",
    ["toolBoost.fishing"] = "[[fishing]]",
    ["toolBoost.fishingBaitPower"] = "Bait",
    ["toolBoost.fishingRarityPower"] = "Bonus Rarity",
    ["toolBoost.fishingReelPower"] = "Reel",
    ["offensiveAccuracyAffinityRating.Chaos"] = [[Combat#Offensive Stats|Choas Accuracy]],
    ["weaponBonus.strength"] = "[[Combat#Offensive Stats|Strength]]",
    ["weaponBonus.intellect"] = "[[Combat#Offensive Stats|intellect]]",
    ["weaponBonus.dexterity"] = "[[Combat#Offensive Stats|dexterity]]",
    ["offensiveAccuracyAffinityRating.Melee"] = "[[Combat#Offensive Stats|Melee Accuracy]]",
    ["offensiveCritical.chance"] = "[[Combat#Offensive Stats|Crit Chance]]",
    ["offensiveCritical.damageMultiplier"] = "[[Combat#Offensive Stats|Crit Mult]]",
    ["armorBonus.agility"] = "[[Combat#Defensive Stats|Agility]]",
    ["armorBonus.protection"] = "[[Combat#Defensive Stats|Protection]]",
    ["armorBonus.stamina"] = "[[Combat#Defensive Stats|Stamina]]",
    ["armorBonus.resistance"] = "[[Combat#Defensive Stats|Resistance]]",
    ["offensiveAccuracyAffinityRating.Range"] = "[[Combat#Offensive Stats|Range Accuracy]]",
    ["offensiveAccuracyAffinityRating.Blunt"] = "[[Combat#Offensive Stats|Blunt Accuracy]]",
}

local tierToDust = {
    [1] = "basic",
    [2] = "basic",
    [3] = "unusual",
    [4] = "singular",
    [5] = "prime",
    [6] = "mythical",
    [7] = "mythical",
    [7.5] = "mythical"
}

local function pairsByKeys(t, f)
    local a = {}
    local orgi_key_type
    local orgi_key_numbered
    for n in pairs(t) do
        if tonumber(n) == nil then
            table.insert(a, n)
            orgi_key_type = "word"
        elseif type(n) == "number" then
            table.insert(a, n)
            orgi_key_type = "int"
        elseif type(n) == "string" and type(tonumber(n) == "number") then
            orgi_key_type = "number"
            table.insert(a, tonumber(n))
        end
    end
    table.sort(a, f)
    local key
    local value
    local i = 0             -- iterator variable
    local iter = function() -- iterator function
        i = i + 1
        if a[i] == nil then
            return nil
        elseif orgi_key_type == "word" or orgi_key_type == "int" then
            key = a[i]
            value = t[a[i]]
        elseif orgi_key_type == "number" then
            key = tostring(a[i])
            value = t[tostring(a[i])]
        end
        return key, value
    end
    return iter
end

local function tablelength(T)
    local count = 0
    for _ in pairs(T) do count = count + 1 end
    return count
end

local function getItemTier(itemData)
    local highestRequiredLevel
    if itemData.requiredLevel then
        -- Highest level of the required skills
        highestRequiredLevel = 0
        for _, level in pairs(itemData.requiredLevel) do
            if level > highestRequiredLevel then
                highestRequiredLevel = level
            end
        end
        highestRequiredLevel = tonumber(string.format("%.1f", highestRequiredLevel / 10))
    end
    local itemTier = itemData.overrideItemTier or highestRequiredLevel or itemData.enchantmentTier or 1
    return itemTier
end

local function getScrapExperience(itemData)
    local item_tier = getItemTier(itemData)
    local xp = scrappingBaseXp * (item_tier ^ scrappingXpPower)
    return math.floor(xp)
end

---fetches an item object
---@param itemId integer|string or string
---@return table|string
local function getItem(itemId)
    local item = itemsData[tostring(itemId)]
    if item then
        return item
    else
        return "Module:Items/data out of date"
    end
end
---gets the augments that have the itemId in thier augmenting cost and returns an array of them
---@param itemId number
---@return table
local function getMatchedAugs(itemId)
    local matchedAugs = {}
    for id, data in pairs(craftingAugmentingData) do
        if data.scrapping then
            for costId, _ in pairsByKeys(data.scrapping) do
                if tonumber(costId) == itemId then
                    matchedAugs[id] = data.scrapping
                end
            end
        end
    end
    return matchedAugs
end
---decides the collase state based on the given string
---@param collapse string
---@return string
local function decideCollapseState(collapse)
    if collapse == "collapseable" then
        collapse = " mw-made-collapsible mw-collapsible"
    elseif collapse == "collapsed" then
        collapse = " mw-made-collapsible mw-collapsible mw-collapsed"
    else
        collapse = ""
    end
    return collapse
end

local function getItemDust(tier)
    if tier <= 2 then
        return "Basic Runic Dust"
    elseif tier <= 3 then
        return "Unusual Runic Dust"
    elseif tier <= 4 then
        return "Singular Runic Dust"
    elseif tier <= 5 then
        return "Prime Runic Dust"
    elseif tier > 5 then
        return "Mythical Runic Dust"
    end
end

local function getItemScrap(item)
    if item.rarity == "common" then
        return "Common Gear Scraps"
    elseif item.rarity == "uncommon" then
        return "Uncommon Gear Scraps"
    elseif item.rarity == "rare" then
        return "Rare Gear Scraps"
    elseif item.rarity == "epic" then
        return "Epic Gear Scraps"
    elseif item.rarity == "legendary" then
        return "Legendary Gear Scraps"
    end
end

local function createImgCell(item)
    local imgCell = mw.html.create('td')
    :wikitext(img._img({item.name, '50'}))
    :done()
    return imgCell
end

local function createNameCell(item)
    local nameCell = mw.html.create('td')
    :wikitext("[[" .. item.name .. "]]")
    :done()
    return nameCell
end

local function createXpCell(item)
    local xpCell = mw.html.create('td')
    :css('text-align', 'center')
    :wikitext(tostring(getScrapExperience(item)))
    :done()
    return xpCell
end

local function createAugBonusCell(item)
    local augBonusCell = mw.html.create('td')
    local augBonusS = ""
    if item.equipmentStats.augmentationBonus then
        local augBonusC = tablelength(item.equipmentStats.augmentationBonus)
        for _, augBonus in ipairs(item.equipmentStats.augmentationBonus) do
            augBonusS = augBonusS .. augmentationBonusNames[augBonus.stat] .. " +" .. augBonus.value
            augBonusC = augBonusC - 1
            if augBonusC > 0 then
                augBonusS = augBonusS .. "<br>"
            end
        end
    elseif not item.equipmentStats.augmentationBonus then
        augBonusS = "-"
    end

    augBonusCell
    :css('text-align', 'center')
    :wikitext(augBonusS)
    :done()

    return augBonusCell
end

local function createCostCell(mItemData, item)
    local costCell = mw.html.create('td')
    local augCostC = tablelength(mItemData)
    for costId, costQuantity in pairsByKeys(mItemData) do
        local costItem = getItem(costId)
        if tonumber(costId) == item.id then
            costCell:tag('span'):css('display', 'inline-block')
                :wikitext(tostring(costQuantity) .. " " .. img._img({costItem.name, '25'}))
                :tag('span'):css('font-weight', 'bold')
                    :wikitext(costItem.name)
                :done()
            :done()
            augCostC = augCostC - 1
            if augCostC > 0  then
                costCell:tag('br')
            end
        else
            costCell:tag('span'):css('display', 'inline-block')
                :wikitext(tostring(costQuantity) .. " " .. img._img({costItem.name, '25', word = 1}))
            :done()
            augCostC = augCostC - 1
            if augCostC > 0  then
                costCell:tag('br')
            end
        end
    end
    return costCell
end

local function createDustCell(item)
    local itemTier = getItemTier(item)
    local dustCell = mw.html.create('td')
    :wikitext(img._img({getItemDust(itemTier), '25', word = 1}))
    :done()
    return dustCell
end

local function createScrapCell(item)
    local scrapCell = mw.html.create('td')
    :wikitext(img._img({getItemScrap(item), '25', word = 1}))
    :done()
    return scrapCell
end

local function genTable(name, collapse)
    local item = getItem(findId._findId({name, "item"}))
    local collapseS = ""
    if collapse == 1 then
        collapseS = " mw-made-collapsible mw-collapsible"
    elseif collapse == 2 then
        collapseS = " mw-made-collapsible mw-collapsible mw-collapsed"
    end
    local matchedAugs = getMatchedAugs(item.id)
    local t = mw.html.create("table")
        :addClass("wikitable sortable jquery-tablesorter" .. collapseS)
        :tag('tr')
            :tag('th')
                :attr("colspan", "2")
                :wikitext("Item")
            :done()
            :tag('th')
                :wikitext("XP")
            :done()
            :tag('th')
                :wikitext("Dust")
            :done()
            :tag('th')
                :wikitext("Scrap")
            :done()
            :tag("th")
                :wikitext("Aug. Bonus")
            :done()
            :tag("th")
                :wikitext("Cost")
            :done()
        :done()
    for mItemId, mItemData in pairs(matchedAugs) do
        local mItem = getItem(mItemId)
        t:tag('tr')
            :node(createImgCell(mItem))
            :node(createNameCell(mItem))
            :node(createXpCell(mItem))
            :node(createDustCell(mItem))
            :node(createScrapCell(mItem))
            :node(createAugBonusCell(mItem))
            :node(createCostCell(mItemData, item))
        :done()
    end
    return t
end

function p.augmentingUses(frame)
    return p._augmentingUses(frame:getParent().args)
end

function p._augmentingUses(_args)
    local name = ""
    if tablelength(_args) == 0 then
        name = pageName
    else
        name = _args[1]
    end
    local t = genTable(name, decideCollapseState(_args["collapse"]))
    return t
end
return p