Line 4: |
Line 4: |
| -- Remi_Scarlet | | -- Remi_Scarlet |
| -- I fucking hate lua. | | -- I fucking hate lua. |
− |
| + | |
| -- 10/24/15 Added colorful blue button as per Wsewo's request. | | -- 10/24/15 Added colorful blue button as per Wsewo's request. |
| | | |
| -- 11/22/17 Modified by がか | | -- 11/22/17 Modified by がか |
− |
| + | |
| -- checks if data is in the array as a key | | -- checks if data is in the array as a key |
− |
| + | |
| function valid(data, array) | | function valid(data, array) |
| local valid = {} | | local valid = {} |
Line 24: |
Line 24: |
| end | | end |
| end | | end |
− |
| + | |
| -- returns a string representation of a table. | | -- returns a string representation of a table. |
| -- cannot do recursive tables. Eg, only single dimensional tables will work | | -- cannot do recursive tables. Eg, only single dimensional tables will work |
Line 48: |
Line 48: |
| return final | | return final |
| end | | end |
− |
| + | |
| -- takes a string and returns string with first letter capitalized | | -- takes a string and returns string with first letter capitalized |
| function capitalize(str) | | function capitalize(str) |
| return (str:gsub("^%l", string.upper)) | | return (str:gsub("^%l", string.upper)) |
| end | | end |
− |
| + | |
| -- "info" should be higher level table of information with eg | | -- "info" should be higher level table of information with eg |
| -- {["A"] = {["1"] = {["xp"]="120", ["main_info"] = "ta-class etc"} | | -- {["A"] = {["1"] = {["xp"]="120", ["main_info"] = "ta-class etc"} |
Line 75: |
Line 75: |
| return size | | return size |
| end | | end |
− |
| + | |
− |
| + | |
| local numCols = 0 | | local numCols = 0 |
| for _,bool in pairs(headers) do | | for _,bool in pairs(headers) do |
| if bool then numCols = numCols + 1 end | | if bool then numCols = numCols + 1 end |
| end | | end |
− |
| + | |
| -- Will be used to uniquely identify each table with the "button" and the "table content". Normally | | -- Will be used to uniquely identify each table with the "button" and the "table content". Normally |
| -- this would be done with like mw-customtoggle-1-1-enemy or whatnot, but since I can't | | -- this would be done with like mw-customtoggle-1-1-enemy or whatnot, but since I can't |
Line 87: |
Line 87: |
| -- rendering to replace the map identifier. | | -- rendering to replace the map identifier. |
| local uniqueID = remiLib.timeHash(info) | | local uniqueID = remiLib.timeHash(info) |
− |
| + | |
| local classString = "mw-customtoggle-" .. tostring(uniqueID) | | local classString = "mw-customtoggle-" .. tostring(uniqueID) |
| local idString = "mw-customcollapsible-" .. tostring(uniqueID) | | local idString = "mw-customcollapsible-" .. tostring(uniqueID) |
− |
| + | |
| local button = mw.html.create('div') | | local button = mw.html.create('div') |
| button | | button |
Line 96: |
Line 96: |
| :addClass("globalbutton") | | :addClass("globalbutton") |
| :wikitext("Show/Hide Nodes and Enemy Encounters") | | :wikitext("Show/Hide Nodes and Enemy Encounters") |
− |
| + | |
| local encounterTable = mw.html.create("table") | | local encounterTable = mw.html.create("table") |
| encounterTable | | encounterTable |
Line 153: |
Line 153: |
| nodeName = nodeName .. "<br>" .. values["label"] | | nodeName = nodeName .. "<br>" .. values["label"] |
| end | | end |
− |
| + | |
| firstCol | | firstCol |
| :wikitext(nodeName) | | :wikitext(nodeName) |
Line 175: |
Line 175: |
| end | | end |
| firstRow:node(mw.html.create("td"):wikitext(text)):css("text-align","center") | | 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 288: |
Line 288: |
| row:node(td) | | row:node(td) |
| end | | end |
− |
| + | |
| encounterTable:node(row) | | encounterTable:node(row) |
| end | | end |
Line 296: |
Line 296: |
| return tostring(button) .. "\n" .. tostring(encounterTable) | | return tostring(button) .. "\n" .. tostring(encounterTable) |
| end | | end |
− |
| + | |
| function splitAndCapitalize(s, split, join) | | function splitAndCapitalize(s, split, join) |
| split = split or "_" | | split = split or "_" |
Line 307: |
Line 307: |
| return table.concat(result, join) | | return table.concat(result, join) |
| end | | end |
− |
| + | |
| -- 1.1. new type pattern parameter: <node>-<pattern number>_<parameter name> | | -- 1.1. new type pattern parameter: <node>-<pattern number>_<parameter name> |
| -- 1.2. old type pattern parameter: <node letter><pattern number>_<parameter name> | | -- 1.2. old type pattern parameter: <node letter><pattern number>_<parameter name> |
Line 327: |
Line 327: |
| return { map = true, name = param } | | return { map = true, name = param } |
| end | | end |
− |
| + | |
| function parsePattern(param) | | function parsePattern(param) |
| local node, number = param:match('^(%w+)-(%d)$') | | local node, number = param:match('^(%w+)-(%d)$') |
Line 335: |
Line 335: |
| return node and { node = node, number = tonumber(number) } | | return node and { node = node, number = tonumber(number) } |
| end | | end |
− |
| + | |
| function markNodes(mapEncounterTable, list, name) | | function markNodes(mapEncounterTable, list, name) |
| if list then | | if list then |
Line 347: |
Line 347: |
| end | | end |
| end | | end |
− |
| + | |
| function debugPrint(x, i) | | function debugPrint(x, i) |
| i = i or 0 | | i = i or 0 |
Line 364: |
Line 364: |
| end | | end |
| end | | end |
− |
| + | |
| function p.encounterTemplate(frame) | | function p.encounterTemplate(frame) |
− |
| + | |
| local bossNode = frame.args.boss_node | | local bossNode = frame.args.boss_node |
| local usedParams = {} | | local usedParams = {} |
| local mapEncounterTable = {} | | local mapEncounterTable = {} |
− |
| + | |
| for param, value in pairs(frame.args) do | | for param, value in pairs(frame.args) do |
| if type(param) == "string" then | | if type(param) == "string" then |
Line 397: |
Line 397: |
| end | | end |
| end | | end |
− |
| + | |
| markNodes(mapEncounterTable, frame.args.final_form, "isFinalForm") | | markNodes(mapEncounterTable, frame.args.final_form, "isFinalForm") |
| markNodes(mapEncounterTable, frame.args.post_final_form, "isPostFinalForm") | | markNodes(mapEncounterTable, frame.args.post_final_form, "isPostFinalForm") |
| markNodes(mapEncounterTable, frame.args.second_phase, "isSecondPhase") | | markNodes(mapEncounterTable, frame.args.second_phase, "isSecondPhase") |
− |
| + | |
| if frame.args.map_xp then | | if frame.args.map_xp then |
| mapEncounterTable.map_xp = frame.args.map_xp | | mapEncounterTable.map_xp = frame.args.map_xp |
| usedParams["Xp"] = true | | usedParams["Xp"] = true |
| end | | end |
− |
| + | |
| debugPrint(mapEncounterTable) | | debugPrint(mapEncounterTable) |
| debugPrint(usedParams) | | debugPrint(usedParams) |
| debugPrint(bossNode) | | debugPrint(bossNode) |
− |
| + | |
| return p.renderEncounterTable(mapEncounterTable, usedParams, bossNode, true) | | return p.renderEncounterTable(mapEncounterTable, usedParams, bossNode, true) |
− |
| + | |
| end | | end |
− |
| + | |
| function p.replaceWordWithWikicode(str) | | function p.replaceWordWithWikicode(str) |
| local nodeInfoImageTable = { | | local nodeInfoImageTable = { |
Line 589: |
Line 589: |
| ["entombed_AA_guardian_princess[%s$]"] = '[[File:Seikan1773Banner.png|2|160px|Entombed Anti-Air Guardian Princess|link=Entombed Anti-Air Guardian Princess]]' | | ["entombed_AA_guardian_princess[%s$]"] = '[[File:Seikan1773Banner.png|2|160px|Entombed Anti-Air Guardian Princess|link=Entombed Anti-Air Guardian Princess]]' |
| } | | } |
− |
| + | |
| if str ~= nil then | | if str ~= nil then |
− |
| + | |
| local originalString = str | | local originalString = str |
| str = string.lower(str) | | str = string.lower(str) |
− |
| + | |
| for vesselName,wikicode in pairs(enemyShipTable) do | | for vesselName,wikicode in pairs(enemyShipTable) do |
| str = str:gsub(vesselName,wikicode) | | str = str:gsub(vesselName,wikicode) |
Line 623: |
Line 623: |
| end | | end |
| end | | end |
− |
| + | |
| function p.test() | | function p.test() |
| return p.encounterTemplate({ | | return p.encounterTemplate({ |
Line 648: |
Line 648: |
| }) | | }) |
| end | | end |
− |
| + | |
| function p.test2() | | function p.test2() |
| return p.encounterTemplate({ | | return p.encounterTemplate({ |
Line 670: |
Line 670: |
| }) | | }) |
| end | | end |
− |
| + | |
| function p.test3() | | function p.test3() |
| return p.encounterTemplate({ | | return p.encounterTemplate({ |
Line 693: |
Line 693: |
| }) | | }) |
| end | | end |
− |
| + | |
| return p | | return p |