Module:Test

From Autistic characters wiki

Documentation for this module may be created at Module:Test/doc

local p = {}

local conversion_table = {
	['a'] = '1 ',
	['b'] = '2 ',
	['c'] = '3 ',
	['d'] = '4 ',
	['e'] = '5 ',
	['f'] = '6 ',
	['g'] = '7 ',
	['h'] = '8 ',
	['i'] = '9 ',
	['j'] = '10 ',
	['k'] = '11 ',
	['l'] = '12 ',
	['m'] = '13 ',
	['n'] = '14 ',
	['o'] = '15 ',
	['p'] = '16 ',
	['q'] = '17 ',
	['r'] = '18 ',
	['s'] = '19 ',
	['t'] = '20 ',
	['u'] = '21 ',
	['v'] = '22 ',
	['w'] = '23 ',
	['x'] = '24 ',
	['y'] = '25 ',
	['z'] = '26 ',
}

function p._convert(args)
	if args == nil then
		return 'Error! Arguments provided are null'
	end
	if args[1] == nil then
		return ''
	end
	local num_str = tostring(args[1])
	local new_str, _ = string.gsub(num_str, '[a-z.]', conversion_table)
	return new_str
end

function p.convert(frame)
	return p._convert(frame.args)
end

return p