WARFRAME Wiki
Advertisement
WARFRAME Wiki
Lotusiconsmall
This template is archived. The content was relevant to a previous formatting of WARFRAME Wiki. Please do not use or delete this template. It is being saved for later potential use.
Description
This template will make a link to the Avionic with a tooltip showing the avionic. It will only accept the exact name of the avionic.
Note: Some avionic articles have an "(Avionic)" suffix which shouldn't be included.
Uses Module:Avionics and its database
Tooltip is Template:Tooltip/Avionic
See also {{Avi/GetValue}}
Syntax
Type {{Avi|<Avionic>|<Custom Name>|<image=Image only?>|<size=(size?)px>|<icon=Icon type: none, icon>}} as a replacement for avionic link.
Input examples

{{Avi|Hyperstrike}}

{{Avi|Seeker Volley|Super Avionic}}

{{Avi|Seeker Volley|Super Avionic|image=qwe|size=30px}}

  • Script error: The function "tooltipImage" does not exist.

{{Avi||Hyperstrike}}

<span class="avionic-tooltip" data-param="Hyperstrike">Hyperstrike</span>

  • Hyperstrike
{{Avi|Hyperstrike}}
{{Avi|Hyperstrike|icon=none}}
{{Avi|Hyperstrike|icon=qwe}}
{{Avi|Hyperstrike|icon=icon}}

Avionics darkHyperstrike Hyperstrike Avionics darkHyperstrike Avionics darkHyperstrike

{{Avi|The One Ring}} Incorrect avionic name gives an error.

  • {{Avionic}} "The One Ring" not found

You should always use the avionic's name without (Avionic) suffix.

  • {{Avi|Warhead}} => Avionics darkWarhead
  • {{Avi|Warhead (Avionic)}} => {{Avionic}} "Warhead (Avionic)" not found

Other Templates

{{#invoke:Avionics|AvionicTable|SortBy|Find|Image?}}


View Selected Type List

{{#invoke:Avionics|AvionicTable|Type|Integrated}} Script error: The function "AvionicTable" does not exist.

View Sorted Category List

{{#invoke:Avionics|AvionicTable|Type}} Script error: The function "AvionicTable" does not exist.

View No Category List

{{#invoke:Avionics|AvionicTable}} Script error: The function "AvionicTable" does not exist.

View Selected Type, with Images List
{{#invoke:Avionics|AvionicTable|Type|Integrated|img}}

Script error: The function "AvionicTable" does not exist.

View Sorted Category, with Images List
{{#invoke:Avionics|AvionicTable|Type||img}}

Script error: The function "AvionicTable" does not exist.

View No Category, with Images List
{{#invoke:Avionics|AvionicTable|||img}}

Script error: The function "AvionicTable" does not exist.


Technical stuff

Database

Codebase

Copied:

Mostly the same as in the text below, but now the work is done by Module:Mods.
Old notes below:
The template checks if first argument matches the name of the mod in Module:Mods/data. This is to check if a mod with that name actually exists. Another possibility would've been to check if an article with that name exists but it's limited to 250 calls per article and is not ideal as it would break on Mods 2.0.

  • If the mod exists, class="mod-tooltip" data-param="{{#var:Name}}" tells javascript that this text wants a tooltip, which is made by {{Tooltip/Mod}}.
  • If the mod doesn't exist, the error is shown instead of a redlink along with Category:Mod Tooltip error added on that page.

If second argument is used -> Category:Mod Tooltip rename is added on the page as to list pages with second argument, as they are harder to edit automatically if there's a need for that. Note: commented out until needed


--Attempting to reformat Module:Mods for Avionics

local p = {}

local AvionicData = mw.loadData( 'Module:Avionics/data' )
local Shared = require( "Module:Shared" )-- skpairs, contains
local Icon = require( "Module:Icon" )

local function getAvionic(name)
    local _av = AvionicData["Avionics"][name]
    if _av ~= nil and _av.Name == name then
        return _av
    else
        for avionicName, Avionic in pairs(AvionicData["Avionics"]) do
            if avionicName == name or Avionic.Name == name then
                return Avionic
            end
        end
    end
end

local function AvionicExists(name, _av)
    if type(_av) ~= table then
        _av = AvionicData["Avionics"][name]
    elseif _av.Name == name then
        return true
    end
    
    if _av ~= nil and _av.Name == name then
        return true
    else
        for avionicName, Avionic in pairs(AvionicData["Avionics"]) do
            if avionicName == name or Avionic.Name == name then
                return true
            end
        end
    end
    return false
end

function p.getValueRaw(frame)
    local AvionicName = frame.args[1]
    local ValName = frame.args[2]
    local Avionic = getAvionic(AvionicName)
    if Avionic ~= nil then
        return Avionic[ValName]
    end
end

function p.getValue(frame)
    local AvionicName = frame.args[1]
    local ValName = frame.args[2]
    return getValue(AvionicName, ValName)
end
function getValueByName(AvionicName, ValName)
    return GetValue(getAvionic(AvionicName), ValName)
end
function getValue(Avionic, ValName)
    
    if(Avionic.Name == nil) then
        return "ERROR: No avionic specified"
    elseif(ValName == nil) then
        return "ERROR: No value specified"
    elseif AvionicExists (Avionic.Name,Avionic) == false then
        return "ERROR: No such avionic "..Avionic.Name.." found"
    end
    
    local UpName = string.upper(ValName)
    if(UpName == "NAME") then
        return Avionic.Name
    elseif(UpName == "IMAGE") then
        if(Avionic.Image ~= nil) then
            return Avionic.Image
        else
            return "Panel.png"
        end
    elseif(UpName == "LINK") then
        if(Avionic.Link ~= nil) then
            return Avionic.Link
        else
            return Avionic.Name
        end
    elseif(UpName == "HOUSE") then
        if(Avionic.House ~= nil) then
            return Avionic.House
        else
            return "None"
        end
    elseif(UpName == "HOUSEICON") then--FIX!████████████████████
        if(Avionic.House ~= nil) then
            return Icon._House(Avionic.House)
        else
            return "None"
        end
    elseif(UpName == "RARITY") then
        if(Avionic.Rarity ~= nil) then
            return Avionic.Rarity
        else
            return "Unknown"
        end
    elseif(UpName == "DESC") then
        if(Avionic.Desc ~= nil) then
            return Avionic.Desc
        else
            return ""
        end
    elseif(UpName == "TRADETAX") then
        if(Avionic.Rarity ~= nil) then
            if(Avionic.Rarity == "Common") then
                return Icon._Item("Credits").." 2,000"
            elseif(Avionic.Rarity == "Uncommon") then
                return Icon._Item("Credits").." 4,000"
            elseif(Avionic.Rarity == "Rare") then
                return Icon._Item("Credits").." 8,000"
            elseif(Avionic.Rarity == "Legendary") then
                return Icon._Item("Credits").." 1,000,000"
            else
                return nil
            end
        else
            return nil
        end
    else
        return AvionicData["Avionics"][Avionic.Name][ValName]
    end
end

function p.buildAvionicTableByRarity()
 
    buildLegendaryTable = ""
    countLegendary = 0
    buildRareTable = ""
    countRare = 0
    buildUncommonTable = ""
    countUncommon = 0
    buildCommonTable = ""
    countCommon = 0
 
    for key, Avionic in Shared.skpairs(AvionicData["Avionics"]) do
--        mw.log(Avionic.Rarity)
 
 
        if Avionic.Rarity == "Legendary" then
            buildLegendaryTable = buildLegendaryTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countLegendary = countLegendary + 1
        elseif Avionic.Rarity == "Rare" then
            buildRareTable = buildRareTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countRare = countRare + 1
        elseif Avionic.Rarity == "Uncommon" then
            buildUncommonTable = buildUncommonTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countUncommon = countUncommon + 1
        elseif Avionic.Rarity == "Common" then
            buildCommonTable = buildCommonTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countCommon = countCommon +1
        end
    end
    
    countTotal = countLegendary + countRare + countUncommon + countCommon
        buildTable = 
countTotal .. "\n" ..
"{| border=\"1\" cellpadding=\"1\" cellspacing=\"1\" class=\"article-table\"\n" ..
"|-\n" ..
"!Legendary\n" .. countLegendary .. "\n" ..
"| " .. buildLegendaryTable .. "\n" ..
"|-\n" ..
"! Rare\n" .. countRare .. "\n" ..
"| " .. buildRareTable .. "\n" ..
"|-\n" ..
"! Uncommon\n" .. countUncommon .. "\n" ..
"| " .. buildUncommonTable .. "\n" ..
"|-\n" ..
"! Common\n" .. countCommon .. "\n" ..
"| " .. buildCommonTable .. "\n" ..
"|}"
 
    return buildTable
end

function p.buildAvionicTableByHouse()
 
    buildSigmaTable = ""
    buildLavanTable = ""
    buildVidarTable = ""
    buildZetkiTable = ""
    
    countSigma = 0
    countLavan = 0
    countVidar = 0
    countZetki = 0
 
--Sigma (default)
--Lavan
--Vidar
--Zetki
 
    for key, Avionic in Shared.skpairs(AvionicData["Avionics"]) do
--        mw.log(Avionic.House)
 
        if     Avionic.House == "Sigma" or Avionic.House == "Default" then
            buildSigmaTable = buildSigmaTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countSigma = countSigma + 1
        elseif Avionic.House == "Lavan" then
            buildLavanTable = buildLavanTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countLavan = countLavan + 1
        elseif Avionic.House == "Vidar" then
            buildVidarTable = buildVidarTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countVidar = countVidar + 1
        elseif Avionic.House == "Zetki" then
            buildZetkiTable = buildZetkiTable .. "[[File:" .. Avionic.Image .. "|114px|link=" .. Avionic.Name .."]]"
            countZetki = countZetki + 1
        end
    end
 
    countTotal = countSigma + countLavan + countVidar + countZetki
        buildTable = 
countTotal .. "\n" .. 
"{| border=\"1\" cellpadding=\"1\" cellspacing=\"1\" class=\"article-table\"\n" ..
"|-\n" ..
"!Sigma\n" .. countSigma .. "\n" ..
"| " .. buildSigmaTable .. "\n" ..
"|-\n" ..
"! Lavan\n" .. countLavan .. "\n" ..
"| " .. buildLavanTable .. "\n" ..
"|-\n" ..
"! Vidar\n" .. countVidar .. "\n" ..
"| " .. buildVidarTable .. "\n" ..
"|-\n" ..
"! Zetki\n" .. countZetki .. "\n" ..
"| " .. buildZetkiTable .. "\n" ..
"|}"
 
    return buildTable
end

function p.getHouseList()
    local hses = {}
    
    for name, Avionic in Shared.skpairs(AvionicData["Avionics"]) do
        if(hses[Avionic.House] == nil) then 
            hses[Avionic.House] = 1 
        else 
            hses[Avionic.House] = hses[Avionic.House] + 1 
        end
    end
    
    local result = "HOUSES:"
    for key, trash in Shared.skpairs(hses) do
        result = result.."\n"..key.." ("..trash..")"
    end
    return result
end

function p.getRarityList()
    local hses = {}
    
    for name, Avionic in Shared.skpairs(AvionicData["Avionics"]) do
        if(hses[Avionic.Rarity] == nil) then 
            hses[Avionic.Rarity] = 1 
        else 
            hses[Avionic.Rarity] = hses[Avionic.Rarity] + 1 
        end
    end
    
    local result = "RARITIES:"
    for key, trash in Shared.skpairs(hses) do
        result = result.."\n"..key.." ("..trash..")"
    end
    return result
end


function p.tooltipText(frame)
    local Name = frame.args ~= nil and frame.args[1]
    local newName = frame.args ~= nil and frame.args[2]
    local Avionic = nil
    if newName == '' then newName = nil end
    
    if Name == nil then
        return '<span style="color:red;">{{[[Template:Avi|Avionic]]}}</span> Insert an avionic name.[[Category:'..'Avionic Tooltip error]]'
    else
        Avionic = getAvionic(Name)
    end
    
    if Avionic == nil then
        return '<span style="color:red;">{{[[Template:Avi|Avionic]]}}</span> "'..Name..'" not found[[Category:'..'Avionic Tooltip error]]'
    else
        local Link = Avionic.Link ~= nil and Avionic.Link or nil
        
        local linkText = ''
        if Link ~= nil and newName ~= nil then
            linkText = Link..'|'..newName
        elseif newName ~= nil then
            linkText = Name..'|'..newName
        elseif Link ~= nil then
            linkText = Link..'|'..Name
        else
            linkText = Name
        end
        
        
        mw.log('data-param="'..getValue(Avionic, 'Image')..'data-name="'..getValue(Avionic, 'desc'))
        local tAvionic ={}
        table.insert(tAvionic,'<span class="avionic-tooltip" data-param="'..getValue(Avionic, 'Image')..'">')
        --20px thumb 200px hover 'data-name="'..getValue(Avionic, 'desc')..
        if Avionic.House ~= nil and frame.args[3] == nil then
            table.insert(tAvionic,'[[File:House'..getValue(Avionic, 'House')..'.png|20px|link='..getValue(Avionic,'LINK')..']]&thinsp;[[')
        elseif frame.args[3] == "none" then
            table.insert(tAvionic, '[[')
        else
            table.insert(tAvionic, '[[File:Avionics_dark.png|20px|link='..getValue(Avionic,'LINK')..']]&thinsp;[[')
        end
        table.insert(tAvionic,linkText..']]</span>')
        
        return table.concat(tAvionic)
    end
end

function p.tooltip(frame)
    local AvionicName = frame.args ~= nil and frame.args[1] or nil
    local renamed = frame.args ~= nil and frame.args[2] or nil
    if renamed == '' or renamed == nil then
        renamed = nil
    end
    
    local Avionic = AvionicData["Avionics"][AvionicName]
 
    local name = getValue(Avionic, "Name")
    --if name ~= nil then
        local image = getValue(AvionicName, "Image")
        if image == nil then
            image = "Panel.png" --default image for Arcanes
        end
        result ={'{| class="Tooltip"\n|-\n| style="padding:0px;"|\n{| class="Sub"\n|-\n| class="Image"| [[File:'..image..'|160px]]\n|-\n| class="Spacer"|'}
        if renamed ~= nil then
            table.insert(result,('\n|-\n! class="Title"|'..renamed..'\n|-\n| class="Spacer"|'))
        end
        local house = getValue(AvionicName, "House")
        local desc = getValue(AvionicName, "Desc")
        local rarity = getValue(AvionicName, "Rarity")
        table.insert(result,('\n|-\n| style="background-color: #0D1B1C; color: #eeeeee; padding: 10px; font-size:13px; line-height: 16px;"|<span style="font-weight: bold;font-size: 14px;">House '..name..':</span> '..'<br>'..'\n|}\n|-\n|}'))
    --else
    --    return "Something went from with Module:Avionics (p.tooltip)"
    --end
    return table.concat(result)
end

-- accepts two parameters: 
-- a string that represents avionic rarity: 'Common', 'Uncommon', 'Rare', 'Legendary', 'All', or ''
-- a string that represents House: 'Sigma', 'Lavan', 'Vidar', 'Zetki', or nil
function p.getAvionicCount(frame)
    local total = 0
    local rarity = frame.args[1]
    local house = frame.args[2]
    
    if (rarity == '' or rarity == nil) then
       rarity = 'All' 
    end
    
    --if (house == '' or house == nil) then
    --    house = 'All'
    --end
    
    for name, Avionic in Shared.skpairs(AvionicData['Avionics']) do
        if ((Avionic['Rarity'] == rarity or rarity == 'All') and 
            (Avionic['House'] == house or house == 'All') and
            not Shared.contains(AvionicData['IgnoreInCount'], name)) then
            
            total = total + 1
        end
    end
    
    return total
end

return p
Advertisement