FANDOM


local p ={}
 
local hslist = require('Module:Hiscore list')
local skillpic = require('Module:Skill clickpic')._main
local addcommas = require('Module:Addcommas')._add
 
local hs_disp = {
	{'Attack','Constitution','Mining'},
	{'Strength','Agility','Smithing'},
	{'Defence','Herblore','Fishing'},
	{'Ranged','Thieving','Cooking'},
	{'Prayer','Crafting','Firemaking'},
	{'Magic','Fletching','Woodcutting'},
	{'Runecrafting','Slayer','Farming'},
	{'Construction','Hunter','Summoning'},
	{'Dungeoneering','Divination','Overall'}
}
 
function p.main(frame)
	local args = frame:getParent().args
	local name = args.Name or args.name
	local datapage = args.Data
	local template = frame:expandTemplate{ title=datapage }
	local data1 = template:gsub('.*|data1=(.*)%s*|time|.*','%1')
	return p._main(name,data1)
end
 
function p._main(name,hs_data)
	local parsed_list = {}
	local hs_skills = mw.text.split(hs_data,' ')
	local hs_names = hslist.i_list()
	for i, v in ipairs(hs_names) do
		local skill_table = {}
		local skill_x = hs_skills[i]
		local skill_data = mw.text.split(skill_x,',')
		skill_table.rank = tonumber(skill_data[1])
		skill_table.level = tonumber(skill_data[2])
		skill_table.xp = tonumber(skill_data[3])
		skill_table.name = hs_names[i]
		parsed_list[i] = skill_table
	end
	local ret_table = mw.html.create('table')
			:addClass('wikitable')
			:css({ ['text-align'] = 'center',
				['width'] = '30%' })
			:tag('caption')
				:wikitext('[http://services.runescape.com/m=hiscore/compare.ws?user1='
				..name:gsub('%s','+')..' '..name..']')
			:done()
	local s_list = hslist.s_list()
	for i, v in ipairs(hs_disp) do
		local rowx = mw.html.create('tr')
		for j, w in ipairs(v) do
			if w then
				local s_data = parsed_list[s_list[w:lower()]]
				local s_name = s_data.name
				local s_lvl = addcommas(s_data.level)
				local s_xp = addcommas(s_data.xp)
				local s_rank = addcommas(s_data.rank)
				rowx:tag('td')
						:attr('title','XP: ' .. s_xp .. '; Rank: ' .. s_rank)
						:wikitext(skillpic(s_name) ..' ' .. s_lvl)
					:done()
			else
				rowx:tag('th'):done()
			end
		end
		rowx:done()
		ret_table:node(rowx)
	end
--[[ Overall on own line? or no?
	local o_data = parsed_list[1]
	local o_lvl = addcommas(o_data.level)
	local o_xp = addcommas(o_data.xp)
	local o_rank = addcommas(o_data.rank)
	ret_table:tag('tr')
			:attr('title','Total XP: ' .. o_xp .. '; Rank: ' .. o_rank)
			:tag('th')
				:attr('colspan','3')
				:wikitext(skillpic() .. o_lvl)
			:done()
		:done()
--]]
	return ret_table
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.