• 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
added order parameter
Line 1: Line 1:  
local getArgs = require("Module:GetArgs")
 
local getArgs = require("Module:GetArgs")
 
local format = require("Module:StringOperations").format
 
local format = require("Module:StringOperations").format
local find = require("Module:Utils").find
+
local Utils = require("Module:Utils")
 
local BaseData = require("Module:BaseData")
 
local BaseData = require("Module:BaseData")
   Line 82: Line 82:  
                     to_node = to_node_color and to_node_ or to_node:match(self._grammar.node)
 
                     to_node = to_node_color and to_node_ or to_node:match(self._grammar.node)
 
                     if from_node and to_node then
 
                     if from_node and to_node then
                         if not find(branching.index, from_node) then
+
                         if not Utils.find(branching.index, from_node) then
 
                             table.insert(branching.index, from_node)
 
                             table.insert(branching.index, from_node)
 
                         end
 
                         end
Line 95: Line 95:  
                         branching[from_node][to_node] = { color = to_node_color }
 
                         branching[from_node][to_node] = { color = to_node_color }
 
                         end
 
                         end
                         if not find(branching[from_node].index, to_node) then
+
                         if not Utils.find(branching[from_node].index, to_node) then
 
                             table.insert(branching[from_node].index, to_node)
 
                             table.insert(branching[from_node].index, to_node)
 
                         end
 
                         end
Line 103: Line 103:  
         end
 
         end
 
     end
 
     end
     table.sort(branching.index)
+
    local sorting
 +
    if args.order then
 +
        local order_nodes = mw.text.split(args.order, "%s*,%s*")
 +
        sorting = function(a, b)
 +
            local ai = Utils.ifind(order_nodes, a)
 +
            local bi = Utils.ifind(order_nodes, b)
 +
            if ai and bi then
 +
                return ai < bi
 +
            else
 +
                return a < b
 +
            end
 +
        end
 +
    else
 +
        sorting = function(a, b)
 +
            return a < b
 +
        end
 +
    end
 +
     table.sort(branching.index, sorting)
 
     for _, from in ipairs(branching.index) do
 
     for _, from in ipairs(branching.index) do
         table.sort(branching[from].index)
+
         table.sort(branching[from].index, sorting)
 
     end
 
     end
 
end
 
end
Line 164: Line 181:  
     ["0 -> 1"] = "Fixed route",
 
     ["0 -> 1"] = "Fixed route",
 
     ["1 -> A, B/battle, C/empty"] = "Random",
 
     ["1 -> A, B/battle, C/empty"] = "Random",
 +
    ["C -> F, G"] = "...",
 +
    ["B -> D, E"] = "...",
 
     ["title"] = "A Custom Title",
 
     ["title"] = "A Custom Title",
 +
    ["order"] = "C, B",
 
     "?",
 
     "?",
 
})
 
})
cssedit, gkautomate
7,060

edits

Navigation menu