FANDOM


-- <nowiki>
 
local p = {}
 
local _defaults = function(s,d) if not s or not s:find('%S') then return d else return s end end
 
local infobox_params = {
	'level',
	'LP',
	'attack',
	'magic',
	'ranged',
	'defence',
	'experience',
	'weakness'
}
function p.main(frame)
	local args = frame:getParent().args
	local all_args = {}
	all_args.universal = {}
	local ret = {}
	local max_i = 0
	local pagename = args['%PAGE%'] or ''
	for i=1,20 do
		if not args['version'..i] then
			break
		else
			all_args['item_s_'..i] = { version_name = args['version'..i] }
			max_i = i
		end
	end
	if max_i == 0 then
		return ''
	end
	all_args.max_value_i = max_i
	for _, v in ipairs(infobox_params) do
		all_args.universal['_'..v..'_'] = _defaults(args[v],'')
		for i=1,max_i do
			all_args['item_s_'..i]['_'..v..'_'] = args[v..'_'..i] or args[v..i]
		end
	end
	for i=1,all_args.max_value_i do
		local rowi = {}
		if i>1 then
			table.insert(rowi,'|-')
			table.insert(rowi,'| [['..pagename..']]')
			table.insert(rowi,'| ')
		end
		for _, v in ipairs(infobox_params) do
			local param_x = all_args['item_s_'..i]['_'..v..'_'] or all_args.universal['_'..v..'_']
			if param_x:find('%$%d+') then
				local p_n = param_x:match('%$(%d+)')
				param_x = all_args['item_s_'..p_n]['_'..v..'_'] or all_args.universal[v]
			end
			table.insert(rowi,'|'..param_x)
		end
		table.insert(rowi,'|')
		rowi = table.concat(rowi,'\n')
		table.insert(ret,rowi)
	end
	return table.concat(ret,'\n')
end
 
function p.main2(frame)
	local args = frame:getParent().args
	if not args.name then
		return ''
	end
	local ret = {' '}
	for _, v in ipairs(infobox_params) do
		table.insert(ret,'| ' .. _defaults(args[v],''))
	end
	return table.concat(ret,'\n')
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.