Content deleted Content added
Make this a carbon copy of Module:Chessboard/Chess (we will change it in a second) |
Revert: Looks like align and header already work (???) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 133:
-- Loop over rows, which are delimited by /
for srow in string.gmatch("/" .. fen, "/%w+") do
srow = srow:gsub("/","") -- clean up row
-- Loop over all letters and numbers in the row
-- Since Lua regexes do not have the | operator, we have
for piece in srow:gmatch( "%w" ) do▼
-- to spell things
local index =
local piece = "" -- Piece can also
local place = 0
local pstart = 0
local pend = 0
local length = srow:len()
while index <= length do
-- Look for a number. Can have multiple digits
pstart, pend = srow:find("%d+", index)
if pstart == index then
index = pend + 1
for k=1,tonumber(piece) do
table.insert(res,' ')
end
else
-- If number not found, look for a
index = pstart + 1
-- l: White (light); d: Black (dark)
local color = piece:match( '%u' ) and 'l' or 'd'
piece = piece:lower()
table.insert(res, piece .. color)
else
index = length + 1 -- Break loop
end
end
end
end
return res
end
|