Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Event shop card: Difference between revisions

From Sekaipedia
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 image = results[1]['image']
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]]',
image,
thumb,
page
page
)
)

Revision as of 03:13, 12 July 2022

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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.