Content deleted Content added
Import from hewiki |
m Pppery moved page Module:Chess games to Module:Chess from pgn without leaving a redirect: Make module name match template name |
||
(2 intermediate revisions by one other user not shown) | |||
Line 13:
function display_game(frame)
local
for k, v in pairs(frame.args) do args[k] = v end
local game = args['pgn']
if not game then error('must have "pgn" parameter') end
local moves = pgn.pgn2fen(game)
local template =
if not template then error('must have "template" parameter') end
local tmTable = {}
Line 27 ⟶ 30:
end
template = mw.text.unstripNoWiki( template )
for arg, val in pairs(
local index = moveToIndex(arg)
if index >= 0 then hydrate(index, val) end
end
for arg, val in pairs(
if arg:match('^from%d+$') then
local hunk = arg:match(('^from(%d+)$'))
toMove =
if not toMove then error (string.format('parameter %s exists, but no parameter to%s', arg, hunk)) end
local fromIndex = moveToIndex(val)
Line 42 ⟶ 45:
if toIndex < 0 then error(string.format('malformed value for parameter to%s', hunk)) end
local comments = {}
local commentsVal =
for comment in commentsVal:gmatch('{([^}]*)}') do table.insert(comments, comment) end
for index = fromIndex, toIndex do hydrate(index, table.remove(comments, 1) or '') end
|