Template:ModuleTableCompareLevels: Difference between revisions

Template page
No edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
<!-- IF YOU ADD/REMOVE PROPERTIES HERE, MAKE SURE YOU CHANGE THEM IN THE CSV TEMPLATE AND LUA MODULE AS WELL -->
 
{{#invoke:ModuleLevelTable|process|
local parsedArray = {}
csv={{#ask:
 
[[-Has subobject::{{{module_name}}}]]
local function addToParsedArray(parsedTable)
|?Module:Name
    parsedArray[#parsedArray+1] = {}
|?Module:VariantID
    for i=1,#parsedTable do
|?Module:Pic
        parsedArray[#parsedArray][i] = parsedTable[i]
|?Module:VersionReleased
    end
|?Module:Rarity
end
|?Module:Socket
 
|?Module:Class
local function parseCSV(csvString) -- csvString is one line
|?Module:MaxEnhancementLevel
    local result = {}
|?Module:CapacityCost0
    for value in string.gmatch(csvString, '([^,]+)') do
|?Module:ExclusiveCategory
        table.insert(result, value)
|?Module:Effect0
    end
|?Module:Effect1
    return result
|?Module:Effect2
end
|?Module:Effect3
 
|?Module:Effect4
local function generateTabberLine(element_level)
|?Module:Effect5
    local tabTitle = "|-|Level " .. tostring(element_level) .. "\n"
|?Module:Effect6
    local tabContent = "This is the content of the tab.\n"
|?Module:Effect7
    return tabTitle .. tabContent
|?Module:Effect8
end
|?Module:Effect9
 
|?Module:Effect10
function p.process(frame)
|format=template
    local csvText = frame.args[1] or ""
|template=Module Level Table CSV
   
|sep=,  
    -- Put all the CSV lines into an array
|link=none
    for line in csvText:gmatch("[^\r\n]+") do
}}
        local parsedLine = parseCSV(line)
}}
        if #parsedLine > 0 then
            addToParsedArray(parsedLine)
        end
    end
   
    if #parsedArray == 0 then
        return "Error: ModuleLevelTable had no results. Report this to Discord!"
    end
 
    -- IMPORTANT! This assumes data is structured EXACTLY in this order!
    --1 Nonsensical invoking ID
    --2 |?Module:Name
    --3 |?Module:Rarity
    --4 |?Module:Socket
    --5 |?Module:Class
    --6 |?Module:MaxEnhancementLevel
    --7 |?Module:CapacityCost0
    --8 |?Module:ExclusiveCategory
    --9 |?Module:Effect0
    --10 |?Module:Effect1
    --11 |?Module:Effect2
    --12 |?Module:Effect3
    --13 |?Module:Effect4
    --14 |?Module:Effect5
    --15 |?Module:Effect6
    --16 |?Module:Effect7
    --17 |?Module:Effect8
    --18 |?Module:Effect9
    --19 |?Module:Effect10
   
    return #parsedArray
 
    local tabCount = parsedArray[1][6] + 1 --Un-upgraded is level 0, so max level + 1
   
    local tabberHeadder = [[
        <tabber>
    ]]
 
    local tabberContent = ""
    for i = 0, tabCount do
        tabberContent = tabberContent .. generateTabberLine(i)
    end
 
    local tabberFooter = [[
        </tabber>
    ]]
   
    return tabberHeadder .. tabberContent .. tabberFooter
end
 
 
 
return p
 
 
--Debug lines
-- local csvText = "ModuleTestPage#_9a88490adf412a0c81fe3a2fa2d78e3c,Test Module Name,Transcendent,Almandine,High-Power Rounds,10,6,Resource,,,,,,,,,,"

Latest revision as of 04:04, 6 June 2024

Error: ModuleLevelTable had no results. Report this to Discord!