Difference between revisions of "Module:Prize pack droppers"

From ALttP Speedrunning Wiki
Jump to: navigation, search
Line 35: Line 35:
  
 
function make_mob_line(mob)
 
function make_mob_line(mob)
return '| style="border: none; vertical-align:middle;" | [[File:' .. mob .. '.png]]'
+
return String.format('| style="border: none; vertical-align:middle;" | [[File:%1$s.png|%1$s]]', mob)
 
end
 
end
  
 
return p
 
return p

Revision as of 12:06, 15 June 2018

Documentation for this module may be created at pack droppers/doc&action=edit&redlink=1 Module:Prize pack droppers/doc

local p = {}

function p.main(frame)
	local args = frame:getParent().args

	local mobs = {}

	for i, v in ipairs(args) do
		mobs[i] = v
	end

	return _main(mobs)
end

function _main(mobs)
	local ret = { '' }

	for i, v in ipairs(mobs) do
		if (i % 8) == 1 then
			table.insert(ret, '|-')
		end

		table.insert(ret, make_mob_line(v))

	end

	local remainder = 8 - (#mobs % 8)

	if remainder ~= 8 then
		table.insert(ret, '! colspan="' .. remainder .. '" | ')
	end

	return table.concat(ret, '\n')
end

function make_mob_line(mob)
	return String.format('| style="border: none; vertical-align:middle;" | [[File:%1$s.png|%1$s]]', mob)
end

return p