Module:Event shop item

From Sekaipedia

Documentation for this module may be created at Module:Event shop item/doc

local getArgs       = require('Module:Arguments').getArgs
local QueryBuilder  = require('Module:QueryBuilder')
local ItemThumbnail = require('Module:Item thumbnail')._main

local data = mw.loadData('Module:Item thumbnail/data')

local p = {}

function p.main(frame)
	local args = getArgs(frame)

	local item     = string.lower(args['item'] or '')
	local count    = args['count'] or 1
	local quantity = args['quantity']
	local cost     = args['cost']
	
	local thumbnail = ''
	local name = ''
	
	if item then
		local qb = QueryBuilder.new()
		qb
			:setTables('items')
			:setFields([[
				_pageName,
				item_name,
				image
			]])
			:addWhere('item_name', '=', item)
	
    	local results = { data[string.lower(item)] }

		if #results > 0 then
			local image = results[1]['image']
			local itemName = results[1]['item_name']
			local page = results[1]['_pageName']
			
			thumbnail = ItemThumbnail{
				image = image,
				size = '75px',
				link = page,
				count = count
			}
			
			name = string.format('[[%s|%s]]', page, itemName)
			
			if tonumber(count) > 1 then
				name = name .. ' ×' ..count
			end
		end
	end

	
	return frame:expandTemplate{
		title = 'Event shop line',
		args = {
			thumbnail = thumbnail,
			name = name,
			quantity = quantity,
			cost = cost
		}
	}
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.