Jump to content

Module:Domino Unicode

From Wikipedia, the free encyclopedia

local getArgs = require('Module:Arguments').getArgs

local p = {}

local hStart = tonumber('0x1f030');
local vStart = hStart + 50;

local function output(direction, num1, num2)
	direction = string.lower(direction);
	num1 = tonumber(num1);
	num2 = tonumber(num2);
	
	local start = hStart;
	if direction == 'h' or direction == 'horizontal' then
		start = hStart;		
	elseif direction == 'v' or direction == 'vertical' then
		start = vStart;
	else
		return '';
	end
	
	local charNum = start;
	if num1 == nil and num2 == nil then
		charNum = start;
	else
		if num2 == nil then
			num2 = num1;
		end
		charNum = start + 1 + (num1 * 7 + num2);
	end
	
	return string.format("%X", charNum);
end

function p.output(frame)
	local args = getArgs(frame);
	return output(args[1], args[2], args[3]);
end

return p;