Module:Hitboxes
From ALttP Speedrunning Wiki
Documentation for this module may be created at Module:Hitboxes/doc
local p = {} local position_x = { 2, 3, 0, -3, -6, 0, 2, -8, 0, -4, -8, 0, -8, -16, 2, 2, 2, 2, 2, -8, 2, 2, -16, -8, -12, 4, -4, -12, 5, -32, -2, 4 } local size_x = { 12, 1, 16, 20, 20, 8, 4, 32, 48, 24, 32, 32, 32, 48, 12, 12, 60, 124, 12, 32, 4, 12, 48, 32, 40, 8, 24, 24, 5, 80, 4, 8 } local position_y = { 0, 3, 4, -4, -8, 2, 0, -16, 12, -4, -8, 0, -10, -16, 2, 2, 2, 2, -3, -12, 2, 10, 0, -12, 16, 4, -4, -12, 3, -16, -8, 10 } local size_y = { 14, 1, 16, 21, 24, 4, 8, 40, 20, 24, 40, 29, 36, 48, 60, 124, 12, 12, 17, 28, 4, 2, 28, 20, 10, 4, 24, 16, 5, 48, 8, 12 } function p.main(frame) local ret = mw.html.create('table') :addClass('wikitable') :addClass('right-1') :addClass('right-2') :addClass('right-3') ret :tag('tr') :tag('th') :wikitext('ID') :done() :tag('th') :wikitext('Attributes') :attr('colspan', 2) :done() :tag('th') :wikitext('Hitbox') :done() :done() for i, v in ipairs(size_x) do local row = ret:tag('tr') row :tag('th') :attr('rowspan', '4') :wikitext(i-1) :css('vertical-align', 'middle') :done() row :tag('th') :wikitext('x') :done() :tag('td') :wikitext(position_x[i]) :done() local hitbox_cell = row:tag('td'):attr('rowspan', '4') hitbox_cell :css({ width = 2.5*(position_x[i] + size_x[i] + 20) .. 'px', height = 2.5*(position_y[i] + size_y[i] + 20) .. 'px', ['padding-top'] = '50px', ['padding-left'] = '150px' }) make_hitbox(hitbox_cell, i) row:done() ret :tag('tr') :tag('th') :wikitext('y') :done() :tag('td') :wikitext(position_y[i]) :done() :done() :tag('tr') :tag('th') :wikitext('w') :done() :tag('td') :wikitext(size_x[i]) :done() :done() :tag('tr') :tag('th') :wikitext('h') :done() :tag('td') :wikitext(size_y[i]) :done() :done() end return ret end function make_hitbox(tag, i) local box = tag:tag('div') box :css({ position = 'relative', zoom = '200%' }) box :tag('div') -- OAM outline :css({ position = 'absolute', left = '1px', top = '1px', width = '14px', height = '14px', outline = '1px solid #FF0000', ['z-index'] = 1 }) :done() :tag('div') -- Cucco image :css({ position = 'absolute', left = 0, top = 0, ['z-index'] = 2 }) :wikitext('[[File:Cucco.png|top|link=]]') :done() :tag('div') -- hitbox :css({ position = 'absolute', background = 'rgba(00, 00, 256, 0.5)', left = position_x[i] .. 'px', top = position_y[i] .. 'px', width = size_x[i] .. 'px', height = size_y[i] .. 'px', ['z-index'] = 3 }) :done() :done() end return p