• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
Undo revision 311448 by Totaku (talk)
Line 1: Line 1:  
local p = {}
 
local p = {}
+
 
 
-- Module for map branching written by
 
-- Module for map branching written by
 
-- Remi_Scarlet
 
-- Remi_Scarlet
 
-- I fucking hate lua.
 
-- I fucking hate lua.
+
 
 
-- 10/24/15 Added colorful blue button thing
 
-- 10/24/15 Added colorful blue button thing
+
-- 5/5/16 Added multiple start location support
 +
 
 
local remiLib = require("Module:RemiLib")
 
local remiLib = require("Module:RemiLib")
+
 
 
function p.renderBranchingTable(graph, collapsed)
 
function p.renderBranchingTable(graph, collapsed)
+
     local uniqueID = remiLib.timeHash()
+
     local uniqueID = remiLib.timeHash(graph)
   
     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 21: Line 21:  
     :addClass("globalbutton")
 
     :addClass("globalbutton")
 
     :wikitext("Show/Hide Branching Rules")
 
     :wikitext("Show/Hide Branching Rules")
+
 
 
     local body = mw.html.create("table")
 
     local body = mw.html.create("table")
 
     body
 
     body
Line 29: Line 29:  
         :attr("id",idString)
 
         :attr("id",idString)
 
         :css("width","300px")
 
         :css("width","300px")
+
       
 
     local titleRow = mw.html.create("tr")
 
     local titleRow = mw.html.create("tr")
 
     local th = mw.html.create("th")
 
     local th = mw.html.create("th")
Line 70: Line 70:  
     -- toTable is a table of all the to's
 
     -- toTable is a table of all the to's
 
     --
 
     --
     local possibleStarts = remiLib.mergeArrays({"START"},remiLib.uppercase)
+
     local possibleNodes = remiLib.mergeArrays({"START", "START-1", "START-2",
     for _,from in pairs(possibleStarts) do
+
        "START-3", "START-4", "START-5"}
 +
      ,remiLib.uppercase)
 +
    -- 5/5/16
 +
    -- Since multiple start paths are possible (Eg, starting from two different places)
 +
    -- adding the ability to specify multiple start points. Assuming no more than 5 start points ever lol.
 +
    -- Yeah yeah I get that it's bad code design. Shut up, I don't care enough to put more than 5 minutes of thought into this.
 +
     for _,from in pairs(possibleNodes) do
 
         if graph[from] ~= nil then
 
         if graph[from] ~= nil then
 
             local toTable = graph[from]
 
             local toTable = graph[from]
Line 85: Line 91:  
             -- instance of the "to" node connecting to a "from" node
 
             -- instance of the "to" node connecting to a "from" node
 
             local isFirstTo = true
 
             local isFirstTo = true
             for _,toNode in pairs(remiLib.uppercase) do
+
             for _,toNode in pairs(possibleNodes) do
 
                 if toTable[toNode] ~= nil then
 
                 if toTable[toNode] ~= nil then
 
                     if not isFirstTo then
 
                     if not isFirstTo then
Line 91: Line 97:  
                     end
 
                     end
 
                     col = mw.html.create("td")
 
                     col = mw.html.create("td")
+
 
 
                     col
 
                     col
 
                         :wikitext(toNode)
 
                         :wikitext(toNode)
Line 109: Line 115:  
     return tostring(button) .. "\n" .. tostring(body)
 
     return tostring(button) .. "\n" .. tostring(body)
 
end  
 
end  
+
 
 
function p.branchingTemplate(frame)
 
function p.branchingTemplate(frame)
 
     -- implementing graph as an adjacency list
 
     -- implementing graph as an adjacency list
Line 117: Line 123:  
         collapsed = false
 
         collapsed = false
 
     end
 
     end
+
 
 
     for param,value in pairs(frame.args) do
 
     for param,value in pairs(frame.args) do
 
         local split = mw.text.split(param,"_")
 
         local split = mw.text.split(param,"_")
Line 123: Line 129:  
         -- second val in split is "to" as above
 
         -- second val in split is "to" as above
 
         -- first and third should be length 1 cuz they should be singular letters
 
         -- first and third should be length 1 cuz they should be singular letters
         if #split == 3 and string.lower(split[2]) == "to" and (#split[1] == 1 or string.lower(split[1]) == "start") and #split[3] == 1 then
+
         if #split == 3 and  
 +
          string.lower(split[2]) == "to" and  
 +
          (#split[1] == 1 or (string.find(string.lower(split[1]),"start") ~= nil)) and  
 +
          (#split[3] == 1 or (string.find(string.lower(split[3]),"start") ~= nil))then
 
             local from = string.upper(split[1])
 
             local from = string.upper(split[1])
 
             local to = string.upper(split[3])
 
             local to = string.upper(split[3])
             if (remiLib.valid(from,remiLib.letters) or string.lower(from) == "start")and remiLib.valid(to,remiLib.letters) then
+
             if (remiLib.valid(from,remiLib.letters) or (string.find(string.lower(split[1]),"start") ~= nil)) and  
 +
              (remiLib.valid(to,remiLib.letters) or (string.find(string.lower(split[3]),"start") ~= nil))then
 
                 if mapGraph[from] == nil then
 
                 if mapGraph[from] == nil then
 
                     mapGraph[from] = {}
 
                     mapGraph[from] = {}
Line 134: Line 144:  
         end
 
         end
 
     end
 
     end
 +
    --local html = remiLib.dictConcat(table.getKeys(mapGraph["START-4"]),"|")
 
     local html = p.renderBranchingTable(mapGraph,collapsed)
 
     local html = p.renderBranchingTable(mapGraph,collapsed)
+
 
 
     return html
 
     return html
+
 
 
end
 
end
+
 
 
return p
 
return p
advmod, cssedit, Moderators, oversight, prechecked, Account Reviewers
18,532

edits

Navigation menu