• 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
m
no edit summary
Line 9: Line 9:  
local Combat2 = require("Module:Combat2")
 
local Combat2 = require("Module:Combat2")
    +
local frame = nil
 
local args = nil
 
local args = nil
 
local ship = nil
 
local ship = nil
 
local target = nil
 
local target = nil
 
local shipCapabilities = {}
 
local shipCapabilities = {}
local frame = nil
      
local debug = {}
 
local debug = {}
   −
function debugLog(s)
+
function debugLog(k, v)
     table.insert(debug, s)
+
     table.insert(debug, (k or "?") .. " = " .. (v or "?"))
 
end
 
end
   Line 236: Line 236:  
end
 
end
   −
local special_functions = {
+
function interpret_args()
    apply = function(args_)
+
    debugLog("#args", #args)
        local frame_ = frame:getParent()
+
    local values = {}
        local template = args_[2]
+
    repeat
        local values = {}
+
         for _, arg in ipairs(args) do
         for i = 3, #args_ do
+
             debugLog("arg", arg)
             table.insert(values, format{
+
            local value = interpret_arg(arg)
                '{{${template}|${arg}}}',
+
            debugLog("value", value)
                 template = template,
+
            if value then
                arg = args_[i]
+
                 table.insert(values, value)
             })
+
             end
 
         end
 
         end
        return frame_:preprocess(table.concat(values, args.concat or ""))
+
    until not sequence or sequence_position > #sequence
    end
+
     debugLog("#values", #values)
}
+
    return table.concat(values, args.concat or "") .. debugString()
 
  −
function interpret_args(args_)
  −
    args = args_
  −
    local special_function = special_functions[args[1]]
  −
     if special_function then
  −
        return special_function(args)
  −
    else
  −
        local values = {}
  −
        debugLog("#args = " .. #args)
  −
        repeat
  −
            for _, arg in ipairs(args_) do
  −
                debugLog("arg = " .. (arg or ""))
  −
                local value = interpret_arg(arg)
  −
                if value then
  −
                    debugLog("value = " .. (value or ""))
  −
                    table.insert(values, value)
  −
                end
  −
            end
  −
        until not sequence or sequence_position > #sequence
  −
        return table.concat(values, args.concat or "") .. debugString()
  −
    end
   
end
 
end
   Line 278: Line 257:  
function Calc.format(frame_, args_)
 
function Calc.format(frame_, args_)
 
     frame = frame_
 
     frame = frame_
     return interpret_args(args_ or Utils.getTemplateArgs(frame_).explicit)
+
     args = args_ or Utils.getTemplateArgs(frame).explicit
 +
    return interpret_args()
 
end
 
end
   Line 303: Line 283:  
             "?cl1",
 
             "?cl1",
 
             "?cl2",
 
             "?cl2",
 +
            "",
 +
            "",
 +
            "",
 
             "",
 
             "",
 
             "-",
 
             "-",
Line 317: Line 300:  
     )
 
     )
 
end
 
end
 +
-- print(p.test())
    
return Calc
 
return Calc
cssedit, gkautomate
6,941

edits

Navigation menu