Jump to content

Module:Domino Unicode: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m use module: arguments
getArgs in the p.output function; compute Unicode codepoint
Line 8: Line 8:
local function output(direction, num1, num2)
local function output(direction, num1, num2)
direction = string.lower(direction);
direction = string.lower(direction);
num1 = tonumber(num1);
local start = hStart;
num2 = tonumber(num2);
local start = hStart;
if direction == 'h' or direction == 'horizontal' then
if direction == 'h' or direction == 'horizontal' then
start = hStart;
start = hStart;
Line 15: Line 17:
start = vStart;
start = vStart;
else
else
return ''
return '';
end
end
Line 31: Line 33:


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



Revision as of 17:47, 13 March 2022

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
	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;