Difference between revisions of "Module:Prize pack droppers"
From ALttP Speedrunning Wiki
(16 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
for i, v in ipairs(args) do | for i, v in ipairs(args) do | ||
− | mobs[i] = | + | local mobt = {} |
+ | mobt.name = v | ||
+ | mobt.ref = args['ref'..i] | ||
+ | mobs[i] = mobt | ||
end | end | ||
Line 14: | Line 17: | ||
function _main(mobs) | function _main(mobs) | ||
− | local ret = {} | + | local ret = { '' } |
for i, v in ipairs(mobs) do | for i, v in ipairs(mobs) do | ||
− | if (i % 8) == | + | if (i % 8) == 1 then |
− | table.insert(ret, '-') | + | table.insert(ret, '|-') |
end | end | ||
− | table.insert(make_mob_line(v)) | + | table.insert(ret, make_mob_line(v)) |
end | end | ||
Line 28: | Line 31: | ||
if remainder ~= 8 then | if remainder ~= 8 then | ||
− | table.insert('! colspan="' .. remainder .. '" | ') | + | table.insert(ret, '! colspan="' .. remainder .. '" | ') |
end | end | ||
Line 35: | Line 38: | ||
function make_mob_line(mob) | function make_mob_line(mob) | ||
− | + | local ret = string.format('| style="border: none; vertical-align:middle;" | [[File:%s.png|%s]]', mob.name, mob.name) | |
+ | if mob.ref then | ||
+ | ret = string.format("%s%s", ret, mob.ref) | ||
+ | end | ||
+ | |||
+ | return ret | ||
end | end | ||
return p | return p |
Latest revision as of 12:58, 19 June 2019
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 local mobt = {} mobt.name = v mobt.ref = args['ref'..i] mobs[i] = mobt 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) local ret = string.format('| style="border: none; vertical-align:middle;" | [[File:%s.png|%s]]', mob.name, mob.name) if mob.ref then ret = string.format("%s%s", ret, mob.ref) end return ret end return p