Module:AchievementTable
Jump to navigation
Jump to search
Documentation for this module may be created at Module:AchievementTable/doc
return {
main = function( frame )
local notavail = frame:expandTemplate{ title = "na" }
local args = frame
if frame == mw.getCurrentFrame() then
args = frame:getParent().args
end
local numCount = -1
if args.category then
numCount = mw.ext.cargo.query( "Achievements", "COUNT(ach_name)=numTotal", { where = 'Achievements.category="' .. args.category .. '"' } )
end
-- Start Achievements Table
local html = mw.html.create( "table" )
:attr( "class", "wikitable list achievement-table" )
:attr( "summary", "List of achievements with the image, name, requirements and rewards." )
:tag( "tr" )
:tag( "th" )
:attr( "colspan", "2" )
:wikitext( "[[Achievements]]" )
if args.category then
html = html
:wikitext( " (" .. numCount[1].numTotal .. ")" )
end
html = html
:tag( "tr" )
:tag( "th" )
:wikitext("Image")
:tag("th")
:wikitext("Name & Details")
:done()
:done()
for _, v in pairs(args) do
local b = mw.text.trim(v)
-- Top header
local a = mw.ext.cargo.query( "Achievements", "ach_name, store_name, ach_image, description, ach_text, gamerscore, trophy, category", { where = 'store_name="' .. b .. '"', ["no html"] = true } )
a = a[1] or { }
if a.store_name then
-- Achievement image cell
html = html
:tag( "tr" )
:tag( "td" )
:wikitext( "[[" .. (a.ach_image or "empty") .. "|224px|class=achievement-image]]" )
:done() -- End Image
-- Achievement name & details cell
:tag( "td" )
:attr( "id", a.store_name )
-- Achievement name
html = html
:tag( "div" )
:attr( "class", "achievement-name" )
if mw.title.getCurrentTitle().text == 'Achievements' then
html = html
:wikitext( a.ach_name )
:done()
else
html = html
:wikitext( "[[Achievements#" .. a.store_name .. "|" .. a.ach_name .. "]]" )
:done()
end -- End Achievement name
-- Achievement text
html = html
:tag ("div")
:wikitext( a.description )
-- End Achievement text
-- Rewards (Xbox Gamerscore and PS5 Trophy)
html = html
:tag ( "div")
:attr( "class", "achievement-rewards" )
if type(tonumber(a.gamerscore)) == "number" then
html = html
:wikitext ( "[[File:Gamerscore.svg|16px|Gamerscore]] " .. a.gamerscore )
end
if a.trophy ~= NIL then
html = html
:tag ("span")
:attr( "class", "achievement-trophies" )
:wikitext ( "[[File:Achievement trophy icon.svg|16px|PlayStation Trophy: " .. a.trophy .."|class=trophy" .. a.trophy .. "]] " .. a.trophy )
end
-- End Rewards
end
end
html = html:allDone()
return tostring(html)
end,
}