(Snapshot: This is a working point.) |
No edit summary |
||
Line 2: | Line 2: | ||
--1 Nonsensical invoking ID | --1 Nonsensical invoking ID | ||
--2 |?Module:Name --Unused, here for debug purposes | --2 |?Module:Name --Unused, here for debug purposes | ||
--3 |?Module:Rarity | --3 |?Module:VariantID | ||
-- | --4 |?Module:Rarity | ||
-- | --5 |?Module:Socket | ||
-- | --6 |?Module:Class | ||
-- | --7 |?Module:MaxEnhancementLevel | ||
-- | --8 |?Module:CapacityCost0 | ||
-- | --9 |?Module:ExclusiveCategory | ||
-- | --10 |?Module:Effect0 | ||
-- | --11 |?Module:Effect1 | ||
-- | --12 |?Module:Effect2 | ||
-- | --13 |?Module:Effect3 | ||
-- | --14 |?Module:Effect4 | ||
-- | --15 |?Module:Effect5 | ||
-- | --16 |?Module:Effect6 | ||
-- | --17 |?Module:Effect7 | ||
-- | --18 |?Module:Effect8 | ||
-- | --19 |?Module:Effect9 | ||
--20 |?Module:Effect10 | |||
-- | -- | ||
--Note that not all Module parameters are being passed in here. Exclusive Descendant, for example | --Note that not all Module parameters are being passed in here. Exclusive Descendant, for example | ||
-- does not need to be displayed in this table. So there's no need to pass it in. | -- does not need to be displayed in this table. So there's no need to pass it in. | ||
-- Make sure before you add anything that it's needed here | -- Make sure before you add anything that it's needed here. | ||
local p = {} | local p = {} | ||
Line 78: | Line 79: | ||
for i = 1, #parsedArray do | for i = 1, #parsedArray do | ||
local row = | local row = | ||
"\n|-\n | "\n|-\n| " .. parsedArray[i][4] .. | ||
" || " .. parsedArray[i][5] .. | " || " .. parsedArray[i][5] .. | ||
" || " .. parsedArray[i][ | " || " .. parsedArray[i][6] .. | ||
" || " .. parsedArray[i][ | " || " .. parsedArray[i][8] .. --TODO: Maths this instead of pulling raw | ||
" || " .. parsedArray[i][ | " || " .. parsedArray[i][9] .. | ||
" || " .. parsedArray[i][10 + element_level] --Effect0 is element 10, plus whatever element level we're looking at | |||
tableContents = tableContents .. row | tableContents = tableContents .. row | ||
Line 115: | Line 116: | ||
-- Removing it puts the first real element back in index 1 | -- Removing it puts the first real element back in index 1 | ||
local largestTabIndex = parsedArray[1][ | local largestTabIndex = parsedArray[1][7] -- We're assuming max upgrade level is always the same. If not, this will need to be handled here. | ||
Line 131: | Line 132: | ||
return frame:preprocess(tabberHeadder .. tabberContent .. tabberFooter) | return frame:preprocess(tabberHeadder .. tabberContent .. tabberFooter) | ||
end | end | ||
return p | return p | ||
Revision as of 22:28, 4 June 2024
Documentation for this module may be created at Module:ModuleLevelTable/doc
-- IMPORTANT! This assumes data is structured EXACTLY in this order! --1 Nonsensical invoking ID --2 |?Module:Name --Unused, here for debug purposes --3 |?Module:VariantID --4 |?Module:Rarity --5 |?Module:Socket --6 |?Module:Class --7 |?Module:MaxEnhancementLevel --8 |?Module:CapacityCost0 --9 |?Module:ExclusiveCategory --10 |?Module:Effect0 --11 |?Module:Effect1 --12 |?Module:Effect2 --13 |?Module:Effect3 --14 |?Module:Effect4 --15 |?Module:Effect5 --16 |?Module:Effect6 --17 |?Module:Effect7 --18 |?Module:Effect8 --19 |?Module:Effect9 --20 |?Module:Effect10 -- --Note that not all Module parameters are being passed in here. Exclusive Descendant, for example -- does not need to be displayed in this table. So there's no need to pass it in. -- Make sure before you add anything that it's needed here. local p = {} local parsedArray = {} local function addToParsedArray(parsedTable) parsedArray[#parsedArray+1] = {} for i=1,#parsedTable do parsedArray[#parsedArray][i] = parsedTable[i] end end function parseCSV(csv) local result = {} local cell = "" local inQuotes = false for i = 1, #csv do local char = csv:sub(i, i) if char == '"' then inQuotes = not inQuotes elseif char == ',' and not inQuotes then table.insert(result, cell) cell = "" elseif char == '\n' and not inQuotes then table.insert(result, cell) cell = "" else cell = cell .. char end end if cell == "" then cell = "Q" end table.insert(result, cell) return result end local function generateTabberLine(element_level) local tabTitle = "\n\n|-| Level " .. tostring(element_level) .. " =\n" local tableHeader = [[ {| class="wikitable" style="width:100%;" |- ! Rarity !! Socket !! Class !! Cost !! Exclusive !! Effect ]] local tableContents = "" for i = 1, #parsedArray do local row = "\n|-\n| " .. parsedArray[i][4] .. " || " .. parsedArray[i][5] .. " || " .. parsedArray[i][6] .. " || " .. parsedArray[i][8] .. --TODO: Maths this instead of pulling raw " || " .. parsedArray[i][9] .. " || " .. parsedArray[i][10 + element_level] --Effect0 is element 10, plus whatever element level we're looking at tableContents = tableContents .. row end local tableFooter = "\n|}" local tabContent = tableHeader .. tableContents .. tableFooter return tabTitle .. tabContent end function p.process(frame) if not frame.args[1] then return "Error: ModuleLevelTable not passed an argument. Report this to Discord!" end local csvText = frame.args[1] -- Put all the CSV lines into an array for line in csvText:gmatch("[^\r\n]+") do if line ~= "" then local parsedLine = parseCSV(line) addToParsedArray(parsedLine) end end if #parsedArray == 0 then return "Error: ModuleLevelTable had no results. Report this to Discord!" end table.remove(parsedArray, 1) --The way that parsing works generates an empty first element. -- I should figure it out and fix it, but... lazy -- Removing it puts the first real element back in index 1 local largestTabIndex = parsedArray[1][7] -- We're assuming max upgrade level is always the same. If not, this will need to be handled here. local tabberHeadder = "<tabber>\n" local tabberContent = "" for i = 0, largestTabIndex do tabberContent = tabberContent .. generateTabberLine(i) end local tabberFooter = "\n</tabber>" return frame:preprocess(tabberHeadder .. tabberContent .. tabberFooter) end return p