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
m (check if thumbnail exists)
m (temporarily disabling cargo query)
Tag: Reverted
Line 24: Line 24:
:addWhere('card_id', '=', cardId)
:addWhere('card_id', '=', cardId)
local results = qb:query()
local results = {}


if #results > 0 then
if #results > 0 then

Revision as of 01:31, 7 April 2023

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 = {}

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