RuneScape Wiki
(Engelse Wiki Treasure Hunter Gems)
Label: sourceedit
 
k (For the love of god don't break)
Label: sourceedit
 
Regel 3: Regel 3:
 
local coins_image = require('Module:Coins image')
 
local coins_image = require('Module:Coins image')
 
local rarity_gems = {
 
local rarity_gems = {
common = 'THGem-common',
+
vaak = 'THGem-vaak',
 
['fairly-common'] = 'THGem-fairly-common',
 
['fairly-common'] = 'THGem-fairly-common',
uncommon = 'THGem-uncommon',
+
ongewoon = 'THGem-ongewoon',
rare = 'THGem-rare',
+
zeldzaam = 'THGem-zeldzaam',
['very-rare'] = 'THGem-very-rare',
+
['heel-zeldzaam'] = 'THGem-heel-zeldzaam',
 
}
 
}
   
 
local rarity_map = {
 
local rarity_map = {
common = 'common',
+
common = 'vaak',
 
['fairly common'] = 'fairly-common',
 
['fairly common'] = 'fairly-common',
 
['fairly-common'] = 'fairly-common',
 
['fairly-common'] = 'fairly-common',
uncommon = 'uncommon',
+
ongewoon = 'ongewoon',
rare = 'rare',
+
zeldzaam = 'zeldzaam',
['very rare'] = 'very-rare',
+
['heel zeldzaam'] = 'heel-zeldzaam',
['very-rare'] = 'very-rare',
+
['heel-zeldzaam'] = 'heel-zeldzaam',
 
}
 
}
   

Huidige versie van 26 jul 2017 om 02:21

Documentatie voor deze module kan aangemaakt worden op de volgende pagina: Module:THGem/doc

-- <pre>
local p = {}
local coins_image = require('Module:Coins image')
local rarity_gems = {
	vaak = 'THGem-vaak',
	['fairly-common'] = 'THGem-fairly-common',
	ongewoon = 'THGem-ongewoon',
	zeldzaam = 'THGem-zeldzaam',
	['heel-zeldzaam'] = 'THGem-heel-zeldzaam',
}

local rarity_map = {
	common = 'vaak',
	['fairly common'] = 'fairly-common',
	['fairly-common'] = 'fairly-common',
	ongewoon = 'ongewoon',
	zeldzaam = 'zeldzaam',
	['heel zeldzaam'] = 'heel-zeldzaam',
	['heel-zeldzaam'] = 'heel-zeldzaam',
}

function p.main(frame)
	local rarity,item,qty,qtyraw,item_page,image
	local args = frame:getParent().args

	rarity = string.lower(args[1] or '')
	local rarity_gem = rarity_gems[rarity_map[rarity]] or 'THGem-none'
	item = args[2]
	qty = args[3] or 'no'
	-- item_page= args[4] or item
	if qty ~= 'no' then
		qty = qty:upper():gsub('[^%dKM]','')
		qtyraw = qty:gsub('K','000'):gsub('M','000000')
		-- Use raw just in case (e.g. 20K instead of 20000)
		qty = qtyraw
		-- Look for 6+ digits
		if qty:find('%d%d%d%d%d%d') then
			-- replace millions first (10m+)
			qty = qtyraw:gsub('^(%d%d%d?%d?)%d%d%d%d%d%d$','%1M')
			-- replace thousands next (100k to 9999k)
			-- this is ignored if millions are replaced
			qty = qty:gsub('^(%d%d%d%d?)%d%d%d$','%1K')
		end
	end
	if item:lower() == 'coins' then
		image = coins_image(qtyraw)
	else
		image = args['img'] or item..'.png'
	end
	local ret = mw.html.create('div')
		:addClass(rarity_gem)
		:css({ width = '66px',
				height = '90px',
				position = 'relative',
				display = 'inline-block'})

	-- Item container
	    :tag('div')
	        :css({display = 'table'})
	            :tag('div')
    	        :css({display = 'table-cell',['vertical-align'] = 'middle'})
        		:tag('span')
        			:css({ width = '35px',
        					height = '35px',
        					position = 'absolute',
        					bottom = '27px',
        					left = '15px',
        					['text-align'] = 'center',
        					['z-index'] = '2' })
        			:wikitext(string.format('[[File:%s|%s|link=%s]]',image,(args['dim'] or '35px'),item))
        		:done()
    		:done()
		:done()
	if qty ~= 'no' then
		qty = qty:upper():gsub('[^%dKM]','')
		-- Look for 6+ digits
		if qty:find('%d%d%d%d%d%d') then
			-- replace millions first (10m+)
			qty = qty:gsub('^(%d%d%d?%d?)%d%d%d%d%d%d$','%1M')
			-- replace thousands next (100k to 9999k)
			-- this is ignored if millions are replaced
			qty = qty:gsub('^(%d%d%d%d?)%d%d%d$','%1K')
		end
		local font_color
		if qty:find('K') then
			font_color = '#FFFFFF'
		elseif qty:find('M') then
			font_color = '#01FF80'
		else
			font_color = '#FFFF00'
		end
		ret:tag('span')
			:css({ position = 'absolute',
					bottom = '48px',
					left = '11px',
					['z-index'] = '3',
					['font-family'] = 'runescape-small',
					['font-size'] = '20px',
					color = font_color,
					['text-shadow'] = '1px 1px 0px black' })
			:wikitext(qty)
		:done()
	end

	return tostring(ret)
end

return p