Module:Equipment

local cargo = mw.ext.cargo local p = {}

local escp = function (str) return (mw.ustring.gsub(str == nil and '' or tostring(str), "'", "\\'")) end

local rarityStars = function (rarity) return string.rep('★', rarity) end

function p.equip(frame) local equipName = frame.args[1] local quantity = frame.args[2] or '' local equip = cargo.query(		'Equipments',		'Equipments._pageName=page, Equipments.Name=name, Equipments.Icon=icon, Equipments.Type=type, Equipments.Rarity=rarity',		{			where = ("Equipments.Name='%s'"):format(escp(equipName)),		}	)

if #equip == 0 then return  .. equipName ..  end

local equip = equip[1]

local showQuantity = string.len(quantity) >= 1

-- Creates HTML Table local tbl = mw.html.create('div') :css('border','none') :css('text-align','center')

local rarity = (equip.rarity == ) and  or ('★' .. equip.rarity) local subtype = frame:expandTemplate{title='EquipmentTypeIcon', args = {equip.type, 'x12px'}} local icon = (equip.icon == ) and  or (''):format(equip.icon, equip.page) local frame = (''):format(equip.page)

local mainIcon = mw.html.create('div') :css('display','inline-block') :css('position','relative') :css('z-index', '1') :wikitext('')

mainIcon:tag('span') -- Item Frame :css('position','absolute') :css('left','0%') :css('top','0%') :css('z-index', '3') :wikitext(frame)

mainIcon:tag('span') -- Subtype Icon :css('position','absolute') :css('left','11.5%') :css('top','2.5%') :css('z-index', '4') :wikitext(subtype)

mainIcon:tag('span') -- Item Icon :css('position','absolute') :css('left','7.5%') :css('top','8.5%') :css('z-index', '2') :wikitext(icon)

mainIcon:tag('span') -- Rarity Icon :css('position','absolute') :css('left','5%') :css('top','62%') :css('color','#ffca00') :css('font-size','110%') :css('text-shadow','1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 2px 0 #000') :css('text-align','right') :css('vertical-align','top') :css('z-index', '3') :wikitext(rarity)

if showQuantity then mainIcon:tag('span') :css('position','absolute') :css('right','1%') :css('top','75%') :css('color','#e0f2f2') :css('font-size','110%') :css('text-shadow','1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 2px 0 #000') :css('text-align','right') :css('vertical-align','top') :css('z-index', '3') :wikitext('x' .. quantity) end

--	tbl:tag('tr') --		:tag('td') -- Full Item Icon tbl:tag('span') :css('border','none') :css('background','none') :css('text-align','center') :css('display', 'inline-block') :wikitext(tostring(mainIcon))

local name =  .. equip.name .. 

if showQuantity then name = name .. ' '

end

return tostring(tbl) end

return p