Module:ItemTooltip

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

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

function p.itemTooltip(frame) local itemName = frame.args[1] local quantity = frame.args[2] or ''

local item = cargo.query(		'Items',		'Items._pageName=page, Items.Name=name, Items.Icon=icon, Items.Subtype=type, Items.Rarity=rarity',		{			where = ("Items.Name='%s'"):format(escp(itemName)),		}	)

if #item == 0 then return  .. itemName ..  end

local item = item[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 = (item.rarity == ) and  or ('★' .. item.rarity) local subtype = frame:expandTemplate{title='ItemSubtypeIcon', args = {item.type, 'x12px'}} local icon = (item.icon == ) and  or (''):format(item.icon, item.page) local frame = (''):format(item.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','6.5%') :css('top','9.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 =  .. item.name .. 

if showQuantity then name = name .. ' '

end

return tostring(tbl) end

return p