Module:Bit field
From ALttP Speedrunning Wiki
Documentation for this module may be created at field/doc&action=edit&redlink=1 Module:Bit field/doc
local p = {} function p.main(frame) local args = frame:getParent().args local max = (args.name15 or args.desc15) and 15 or 7 local hexvalue = max==15 and "$%04X" or "$%02X" local ret = mw.html.create('table') :addClass('wikitable') :addClass('right-1') ret :tag('tr') :tag('th') :wikitext('Bit') :done() :tag('th') :wikitext('Name') :done() :tag('th') :wikitext('Description') :done() :tag('th') :attr('colspan','2') :wikitext('Value') :done() for i=max,0,-1 do local v = 2^i ret :tag('tr') :tag('td') :wikitext(i) :done() :tag('td') :wikitext(args['name'..i] or 'b'..i) :done() :tag('td') :wikitext(args['desc'..i] or 'Unused') :done() :tag('td') :wikitext('2') :tag('sup') :wikitext(i) :done() :done() :tag('td') :attr('title', string.format('%s in decimal', v)) :wikitext(string.format(hexvalue, v)) :done() :done() end return ret end return p