Module:Slope
From ALttP Speedrunning Wiki
Documentation for this module may be created at Module:Slope/doc
local p = {} local slope_symbols = { ['◢'] = { '/', '/bottom', 'bottom/', 'acute', 'acutebottom', 'bottomacute' }, ['◣'] = { '\\', '\\bottom', 'bottom\\', 'grave', 'gravebottom', 'bottomgrave' }, ['◤'] = { '/', '/top', 'top/', 'acute', 'acutetop', 'topacute' }, ['◥'] = { '\\', '\\top', 'top\\', 'grave', 'gravetop', 'topgrave' } } function p.main(frame) local args = frame:getParent().args local slope = args[1] or '' slope = slope:lower():gsub(' ','') local ret for v, w in pairs(slope_symbols) do for _, x in ipairs(w) do if slope == x then ret = v break end end end if not ret then error('No valid slope defined') end return string.format('<span style="font-size:110%;">%s</span>', ret) end function p.selfdoc() local ret = mw.html.create('table') :addClass('center-1') ret :tag('tr') :tag('th') :wikitext('Slope') :done() :tag('th') :wikitext('Valid keys') :done() :done() for v, w in pairs(slope_symbols) do local temp_row = ret:tag('tr') temp_row:tag('td') :wikitext(v) :done() local temp_text = { } for _, x in ipairs(w) do table.insert(temp_text, string.format('<code>%s</code>', x)) end temp_row:tag('td') wikitext(table.concat(temp_text, ', ')) :done() temp_row:done() end return ret end return p