Module:Chessboard: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 9:
local reverse = string.lower(frame.args['reverse'] or '') == "true"
 
function rownumFromRow(row)
return reverse and (row + 1) or (8 - row)
end
function filecharFromFile(file)
file = reverse and (8 - file) or (file + 1)
return string.sub("abcdefgh", file, file)
end
function coord(ind)
return (reverse and (7 - ind) * size) or ind * size
Line 16 ⟶ 25:
local pieceColor = string.match(piece, '%u') and 'l' or 'd'
piece = string.lower(piece)
local filecharalt = string.subformat("abcdefgh%s%d %s %s", filecharFromFile(file), +rownumFromRow(row), 1p.colornames[pieceColor], file + 1p.piecenames[piece])
local alt = string.format("%s%d %s %s", filechar, row + 1, p.colornames[pieceColor], p.piecenames[piece])
local img = string.format('[[File:Chess %s%st45.svg|%dx%dpx|alt=%s|%s]]', piece, pieceColor, size, size, alt, alt)
return string.format('<div style="position:absolute;z-index:3;top:%dpx;left:%dpx;">%s</div>\n', coord(row), coord(file), img)