Line 8: |
Line 8: |
| function valid(data, array) | | function valid(data, array) |
| local valid = {} | | local valid = {} |
− | for i = 1, #array do | + | if array ~= nil then |
− | valid[array[i]] = true
| + | for i = 1, #array do |
− | end
| + | valid[array[i]] = true |
− | if valid[data] then
| + | end |
− | return true
| + | if valid[data] then |
− | else
| + | return true |
− | return false
| + | else |
| + | return false |
| + | end |
| end | | end |
| end | | end |
Line 127: |
Line 129: |
| end | | end |
| firstRow:node(firstCol) | | firstRow:node(firstCol) |
− | firstRow:node(mw.html.create("td"):wikitext("Pattern 1")) | + | local text = "Pattern 1" |
| + | if values[1]["isFinalForm"] ~= nil then |
| + | text = "<span style='color:red'>" .. text .."<br>" .. "Final Form</span>" |
| + | end |
| + | firstRow:node(mw.html.create("td"):wikitext(text)):css("text-align","center") |
| + | |
| -- since first row with rowspan is handled differently, just | | -- since first row with rowspan is handled differently, just |
| -- do it separately | | -- do it separately |
Line 179: |
Line 186: |
| if type(values[i]) == "table" then | | if type(values[i]) == "table" then |
| local row = mw.html.create("tr") | | local row = mw.html.create("tr") |
− | row:node(mw.html.create("td"):wikitext("Pattern "..i)) | + | local text = "Pattern " .. i |
| + | if values[i]["isFinalForm"] ~= nil then |
| + | text = "<span style='color:red'>" .. text .."<br>" .. "Final Form</span>" |
| + | end |
| + | row:node(mw.html.create("td"):wikitext(text)):css("text-align","center") |
| for _,param in pairs(paramOrder) do | | for _,param in pairs(paramOrder) do |
| if headers[param] then | | if headers[param] then |
Line 238: |
Line 249: |
| -- map all the nodes we'll be using into mapEncounterTable -> {"A":true,"B"=true} etc | | -- map all the nodes we'll be using into mapEncounterTable -> {"A":true,"B"=true} etc |
| for k,v in pairs(frame.args) do | | for k,v in pairs(frame.args) do |
− | for i,letter in pairs(validNodeLetters) do | + | if string.lower(k) ~= "boss_node" and string.lower(k) ~= "final_form" then |
− | local split = mw.text.split(k,"_")
| + | for i,letter in pairs(validNodeLetters) do |
− | if valid(letter,mw.text.split(string.upper(split[1]),"")) then
| + | local split = mw.text.split(k,"_") |
− | mapEncounterTable[letter] = {}
| + | if valid(letter,mw.text.split(string.upper(split[1]),"")) then |
− | if letter>bossNode then
| + | mapEncounterTable[letter] = {} |
− | bossNode = letter
| + | if letter>bossNode then |
| + | bossNode = letter |
| + | end |
| end | | end |
| end | | end |
Line 259: |
Line 272: |
| for letter,_ in pairs(mapEncounterTable) do | | for letter,_ in pairs(mapEncounterTable) do |
| -- if letter is equal to the first letter in nodePattern, | | -- if letter is equal to the first letter in nodePattern, |
− | if letter == mw.text.split(string.upper(nodePattern),"")[1] then | + | if letter == mw.text.split(string.upper(nodePattern),"")[1] and nodePattern ~= "final_form" and nodePattern ~= nil then |
| if mw.text.split(nodePattern,"")[2] ~= "_" then | | if mw.text.split(nodePattern,"")[2] ~= "_" then |
| local patternNum = mw.text.split(mw.text.split(nodePattern,"_")[1],"")[2] | | local patternNum = mw.text.split(mw.text.split(nodePattern,"_")[1],"")[2] |
| | | |
| -- If the second char is not a number, invalid. | | -- If the second char is not a number, invalid. |
− | if tonumber(patternNum) == nil then return "<span style='color:red'>Please check your module invocation arguments. Something is invalid</span>" end | + | if tonumber(patternNum) == nil and nodePattern ~= "final_form" then |
| + | --return patternNum |
| + | return "<span style='color:red'>Please check your module invocation arguments. Something is invalid</span>" |
| + | end |
| patternNum = tonumber(patternNum) | | patternNum = tonumber(patternNum) |
| local nodePatternSplit = mw.text.split(nodePattern,"_") | | local nodePatternSplit = mw.text.split(nodePattern,"_") |
Line 272: |
Line 288: |
| -- B3_form's param name is just "Form" | | -- B3_form's param name is just "Form" |
| -- notice the conversion of capitalization | | -- notice the conversion of capitalization |
− | for i = 2, #nodePatternSplit do | + | if nodePatternSplit ~= nil then |
− | paramName = paramName .. capitalize(nodePatternSplit[i])
| + | for i = 2, #nodePatternSplit do |
− | if i ~= #nodePatternSplit then
| + | paramName = paramName .. capitalize(nodePatternSplit[i]) |
− | paramName = paramName .. " "
| + | if i ~= #nodePatternSplit then |
| + | paramName = paramName .. " " |
| + | end |
| end | | end |
| end | | end |
Line 302: |
Line 320: |
| end | | end |
| | | |
− | html = p.renderEncounterTable(mapEncounterTable,usedParams, bossNode) | + | if frame.args["final_form"] ~= nil then |
| + | local nodeAndPatterns = mw.text.split(frame.args["final_form"]," ") |
| + | for _,nodePattern in pairs(nodeAndPatterns) do |
| + | for _,validLetter in pairs(validNodeLetters) do |
| + | if validLetter == mw.text.split(nodePattern,"")[1] then |
| + | local patternNum = mw.text.split(nodePattern,"")[2] |
| + | if tonumber(patternNum) ~= nil then |
| + | patternNum = tonumber(patternNum) |
| + | |
| + | if mapEncounterTable[validLetter][patternNum] ~= nil then |
| + | mapEncounterTable[validLetter][patternNum]["isFinalForm"] = true |
| + | end |
| + | end |
| + | end |
| + | end |
| + | end |
| + | end |
| + | html = p.renderEncounterTable(mapEncounterTable,usedParams,bossNode) |
| | | |
| return html | | return html |
Line 438: |
Line 473: |
| end | | end |
| end | | end |
− | if count == 3 then | + | if count == 3 and str ~= nil then |
| str = str:sub(0,i) .. "<br>" .. str:sub(i+1,#str) | | str = str:sub(0,i) .. "<br>" .. str:sub(i+1,#str) |
| end | | end |