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

Difference between revisions of "Module:EquipmentLink"

From Kancolle Wiki
Jump to navigation Jump to search
(Created page with "local getArgs = require("Module:GetArgs") local U = require("Module:Utils") local F = require("Module:Formatting") local Equipment = require("Module:Equipment") local Equipmen...")
 
m
Line 1: Line 1:
 
local getArgs = require("Module:GetArgs")
 
local getArgs = require("Module:GetArgs")
local U = require("Module:Utils")
 
 
local F = require("Module:Formatting")
 
local F = require("Module:Formatting")
 
local Equipment = require("Module:Equipment")
 
local Equipment = require("Module:Equipment")
Line 35: Line 34:
  
 
--[[
 
--[[
 +
local U = require("Module:Utils")
 +
 
U.registerFormatTests(EquipmentLink, {
 
U.registerFormatTests(EquipmentLink, {
 
     { "Prototype 51cm Twin Gun Mount" },
 
     { "Prototype 51cm Twin Gun Mount" },

Revision as of 03:20, 24 March 2017

Documentation for this module may be created at Module:EquipmentLink/doc

local getArgs = require("Module:GetArgs")
local F = require("Module:Formatting")
local Equipment = require("Module:Equipment")
local EquipmentCardKai = require("Module:EquipmentCardKai")

local EquipmentLink = {}

function EquipmentLink.format(frame, args)

    args = args or getArgs{ frame = frame:getParent() }

    local name = args[1] or "??"
    local text = args[2]
    local link = args.link
    local image = args.image
    local icon = args.icon

    local card = EquipmentCardKai:Asset({ name })

    local formatted_link
        = image
        and EquipmentCardKai:Asset({ name, size = image, link = link or name })
        or F:format_link(link or name, text or name)

    local formatted_icon = ""
    if icon then
        local equipment = Equipment(name)
        formatted_icon = F:format_image{ F:format_equipment_icon(equipment:icon()) }
    end

    return F:class_span("advanced-tooltip", nil, formatted_icon .. formatted_link .. F:class_div("tooltip-contents", nil, card))

end

--[[
local U = require("Module:Utils")

U.registerFormatTests(EquipmentLink, {
    { "Prototype 51cm Twin Gun Mount" },
    { "Type 4 Passive Sonar", link = "Sonar" },
    { "Prototype 51cm Twin Gun Mount", "P51cm" },
    { "Prototype 51cm Twin Gun Mount", image = "50px" },
    { "Prototype 51cm Twin Gun Mount", icon = "x" },
    { },
})
-- p.run_format_tests()
]]--

return EquipmentLink