Jump to content

Module:Sandbox/Jbzdarkid/NecroTable

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Jbzdarkid (talk | contribs) at 01:40, 19 February 2023. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.table(frame)
	local output = '<table cellpadding="0" style="margin:0px; border:1px; border-color:black; border-collapse:collapse; background-color:lightgray; text-align:center"><tr>'
	local grid = frame.args['grid']
	for j = 1, #grid do
		local chr = grid:byte(j)
		if (chr == string.byte(" "))  then output = output .. '<td></td>' end
		if (chr == string.byte("^"))  then output = output .. '<td style="background-color:skyblue;">↑</td>' end
		if (chr == string.byte("v"))  then output = output .. '<td style="background-color:skyblue;">↓</td>' end
		if (chr == string.byte("<"))  then output = output .. '<td style="background-color:skyblue;">←</td>' end
		if (chr == string.byte(">"))  then output = output .. '<td style="background-color:skyblue;">→</td>' end
		if (chr == string.byte("\n")) then output = output .. '</tr><tr>' end
		if (chr >= string.byte("1") and chr <= string.byte("9")) then
			local ord = chr - string.byte("0")
			output = output .. '<td style="background-color:' .. frame.args['color-' .. ord] .. '">[[File:' .. frame.args['image-' .. ord] .. '|24x24px]]</td>'
		end
	end
	output = output .. '</tr></table>'
	return output
end

return p