Module:Skill
Jump to navigation
Jump to search
Module used by Template:Skill to do a cargo query and display a little infobox about the skills.
The above documentation is transcluded from Module:Skill/doc. (edit | history)
local p = {}
function p.main(frame)
if frame == mw.getCurrentFrame() then
args = require('Module:ProcessArgs').merge(true)
else
frame = mw.getCurrentFrame()
end
if (args.name == nil or args.name == '') then
return frame:preprocess('<span style="color:red">Error! You must enter a <code>name</code> parameter!</span>')
end
local skill = args.name
local result = mw.ext.cargo.query(
'Skills',
'_pageName, name, image, cooldown, consumes, cost, skilltype',
{
where = '_pageName="' .. skill .. '"',
limit = 1
}
)
if not (result[1]) then
return frame:preprocess('<span style="color:red">Error! Could not get data for '.. skill ..'!</span>')
end
local descResult = mw.ext.cargo.query(
'Descriptions',
'_pageName, description',
{
where = '_pageName="' .. skill .. '"',
limit = 1
}
)
if not (descResult[1].description) then
return frame:preprocess('<span style="color:red">Error! Could not get description for '.. skill ..'!</span>')
end
-- our Query results
local skillData = result[1]
local desc = descResult[1].description
-- Build the HTML
local html = mw.html.create()
local mainStyle = 'padding: 0px; margin: 0px; min-width: 300px; border: 1px solid #222; color: #FFF; background-color: #000;'
local mainDiv = html:tag('div'):addClass('skillbox'):cssText(mainStyle)
-- Header Div
local headerStyle = 'float: left; background-color: #151515; width: 100%; height: 25px; vertical-align: middle; text-align: center; font-size: 15pt; font-weight: 475; line-height: 25px !important;'
local headerDiv = mainDiv:tag('div'):addClass('heading'):cssText(headerStyle)
headerDiv:wikitext('[['..skill..']]')
-- Image
mainDiv:tag('div'):cssText('float:left; padding-bottom: 0px !important; padding-right: 5px'):wikitext(frame:preprocess('[[File:' .. skillData.image .. '|84x128px|link=' .. skillData._pageName .. '|frameless]]'))
-- Skill Info
-- costs (purchase and activate costs)
local costsStyle = 'display: block; text-align: left; padding-top: 3px; padding-right: 5px; margin-left: 5px;'
local costsDiv = mainDiv:tag('div'):cssText(costsStyle):addClass('skillDesc')
local costsOutput = skillData.cost
if (skillData.skilltype == 'Passive') then
costsOutput = costsOutput .. ' | <span style="color: #555">Passive</span>'
else
if ((args.manacost ~= nil and args.manacost ~= '') or (args.staminacost ~= nil and args.staminacost ~= '') or (args.cooldown ~= nil and args.cooldown ~= '')) then
costsOutput = costsOutput .. ' |'
if (args.manacost ~= nil and args.manacost ~= '') then costsOutput = costsOutput .. ' ' .. args.manacost .. ' {{mana}}' end
if (args.staminacost ~= nil and args.staminacost ~= '') then costsOutput = costsOutput .. ' ' .. args.staminacost .. ' {{stamina}}' end
if (args.cooldown ~= nil and args.cooldown ~= '') then costsOutput = costsOutput .. ' ' .. args.cooldown .. 's {{cooldown}}' end
end
end
costsDiv:wikitext(frame:preprocess('<b style="font-size: 87%">'..costsOutput..'</b>'))
-- and just chuck the description in the remaining div area
mainDiv:tag('hr'):cssText('margin-right: 5px; margin-bottom: 8px;')
mainDiv:wikitext(frame:preprocess('<i style="display: blockl font-size: 90%; line-height: 18px;">' .. desc .. '</i>'))
mainDiv:tag('div'):cssText('clear: both;'):done()
return html:done()
end
return p