Content deleted Content added
No edit summary |
more lua-like |
||
Line 1:
function chessboard( fen, size, reverse )
local p = {▼
}▼
p.f = function(frame)▼
local fen = frame.args['fen']▼
end▼
function coord( ind ) return ( reverse and ( 7 - ind ) * size ) or ind * size end▼
▲ return string.sub("abcdefgh", file + 1, file + 1)
end▼
▲ return (reverse and (7 - ind) * size) or ind * size
end▼
local file = 0
▲ local pieceColor = string.match(piece, '%u') and 'l' or 'd'
for piece in s:gmatch( "%w" ) do -- if a digit, increment "file" by the digit. else, add the piece _and_ increment file by 1
▲ piece = string.lower(piece)
file = file + ( piece:match("%d") or piecediv( piece, row, file, res ) )
▲ local alt = string.format("%s%s %s %s", filecharFromFile(file), rownumFromRow(row), p.colornames[pieceColor], p.piecenames[piece] or piece)
end
▲ 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)
end▼
table.insert(result, string.format([=[
<div class="chess-fen" style="position:relative;">
for piece in string.gmatch(s, "%\w") do▼
[[File:Chessboard480.png|%dx%dpx|link=]]
]=], s8, s8))
▲ return result
▲ result = result .. oneRow(srow, row)
table.insert(result, '</div>')
▲ row = row + 1
▲ return result
end
return
local t = chessboard( args.fen, args.size or 30, ( args.reverse or '' ):lower() == "reverse" )
return table.concat( t, "\n" )
▲ end
▲}
|