Module:Slope

From ALttP Speedrunning Wiki
Revision as of 14:25, 22 December 2018 by Kan (talk | contribs) (Created page with "local p = {} local slope_symbols = { ['◢'] = { '/', '/bottom', 'bottom/', 'acute', 'acutebottom', 'bottomacute' }, ['◣'] = { '\\', '\\bottom', 'bottom\\', 'grave', 'gra...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

return p