Content added Content deleted
m (temporarily disabling cargo query) Tag: Reverted |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 16: | Line 16: | ||
local qb = QueryBuilder.new() |
local qb = QueryBuilder.new() |
||
qb |
qb |
||
:setTables(' |
:setTables('cards') |
||
:setFields([[ |
:setFields([[ |
||
_pageName, |
_pageName, |
||
Line 24: | Line 24: | ||
:addWhere('card_id', '=', cardId) |
:addWhere('card_id', '=', cardId) |
||
local results = |
local results = qb:query() |
||
if #results > 0 then |
if #results > 0 then |
Latest revision as of 17:01, 30 April 2023
This module depends on the following other modules: |
This module uses the following Cargo tables: |
To generate {{Event shop card}}, invoke the main function.
local getArgs = require('Module:Arguments').getArgs
local QueryBuilder = require('Module:QueryBuilder')
local p = {}
function p.main(frame)
local args = getArgs(frame)
local cardId = args['card id']
local cost = args['cost']
local thumbnail = ''
local name = ''
if cardId and tonumber(cardId) > 0 then
local qb = QueryBuilder.new()
qb
:setTables('cards')
:setFields([[
_pageName,
card_name,
thumbnail
]])
:addWhere('card_id', '=', cardId)
local results = qb:query()
if #results > 0 then
local thumb = results[1]['thumbnail']
local cardName = results[1]['card_name']
local page = results[1]['_pageName']
thumbnail = '?'
if thumb ~= nil and thumb ~= '' then
thumbnail = string.format(
'[[File:%s|75px|link=%s]]',
thumb,
page
)
end
name = string.format('[[%s|%s]]', page, cardName)
end
end
return frame:expandTemplate{
title = 'Event shop line',
args = {
thumbnail = thumbnail,
name = name,
quantity = 1,
cost = cost
}
}
end
return p