Content added Content deleted
(Created page with "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 count = args['count'] or 1 local quantity = args['quantity'] local cost = args['cost'] local thumbnail = '' local name = '' if cardId and tonumber(cardId) > 0 then local qb = QueryBuilder.new() qb :setTables('Cards') :setFields([...") |
(fixed field) |
||
Line 8: | Line 8: | ||
local cardId = args['card id'] |
local cardId = args['card id'] |
||
local count = args['count'] or 1 |
|||
local quantity = args['quantity'] |
|||
local cost = args['cost'] |
local cost = args['cost'] |
||
Line 29: | Line 27: | ||
if #results > 0 then |
if #results > 0 then |
||
local |
local thumb = results[1]['thumbnail'] |
||
local cardName = results[1]['card_name'] |
local cardName = results[1]['card_name'] |
||
local page = results[1]['_pageName'] |
local page = results[1]['_pageName'] |
||
Line 35: | Line 33: | ||
thumbnail = string.format( |
thumbnail = string.format( |
||
'[[File:%s|80px|link=%s]]', |
'[[File:%s|80px|link=%s]]', |
||
thumb, |
|||
page |
page |
||
) |
) |
Revision as of 03:13, 12 July 2022
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 = string.format(
'[[File:%s|80px|link=%s]]',
thumb,
page
)
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