Difference between revisions of "Module:Slope"
From ALttP Speedrunning Wiki
(Created page with "local p = {} local slope_symbols = { ['◢'] = { '/', '/bottom', 'bottom/', 'acute', 'acutebottom', 'bottomacute' }, ['◣'] = { '\\', '\\bottom', 'bottom\\', 'grave', 'gra...") |
(doesn't even have enough of an effect to be worth it lol) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
['◢'] = { '/', '/bottom', 'bottom/', 'acute', 'acutebottom', 'bottomacute' }, | ['◢'] = { '/', '/bottom', 'bottom/', 'acute', 'acutebottom', 'bottomacute' }, | ||
['◣'] = { '\\', '\\bottom', 'bottom\\', 'grave', 'gravebottom', 'bottomgrave' }, | ['◣'] = { '\\', '\\bottom', 'bottom\\', 'grave', 'gravebottom', 'bottomgrave' }, | ||
− | ['◤'] = { | + | ['◤'] = { '/top', 'top/', 'acutetop', 'topacute' }, |
− | ['◥'] = { | + | ['◥'] = { '\\top', 'top\\', 'gravetop', 'topgrave' } |
} | } | ||
Line 29: | Line 29: | ||
end | end | ||
− | return string.format('< | + | return ret |
+ | end | ||
+ | |||
+ | function p.selfdoc() | ||
+ | local ret = mw.html.create('table') | ||
+ | :addClass('wikitable 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 | end | ||
return p | return p |
Latest revision as of 13:45, 22 December 2018
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/', 'acutetop', 'topacute' }, ['◥'] = { '\\top', 'top\\', '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 ret end function p.selfdoc() local ret = mw.html.create('table') :addClass('wikitable 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