5233
редагування
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 58: | Рядок 58: | ||
local table_content = mw.ustring.sub(rating_section, table_start, table_end + 1) | local table_content = mw.ustring.sub(rating_section, table_start, table_end + 1) | ||
-- | -- Розбиваємо таблицю на рядки (між |- ) | ||
local | local current_row = {} | ||
for | local all_rows = {} | ||
for line in mw.ustring.gmatch(table_content .. "\n", "([^\n]*)\n") do | |||
line = mw.text.trim(line) | |||
if line == "|-" then | |||
if #current_row > 0 then | |||
table.insert(all_rows, current_row) | |||
end | |||
current_row = {} | |||
elseif mw.ustring.match(line, "^|[^-}]") then | |||
-- Це комірка (починається з | але не |- або |}) | |||
local cell_content = mw.ustring.gsub(line, "^|%s*", "") | |||
table.insert(current_row, cell_content) | |||
end | |||
end | end | ||
-- Додаємо останній рядок | -- Додаємо останній рядок якщо є | ||
if #current_row > 0 then | |||
if | table.insert(all_rows, current_row) | ||
table.insert( | |||
end | end | ||
for _, row in ipairs( | -- Шукаємо рядок з гравцем | ||
-- | for _, row in ipairs(all_rows) do | ||
-- row[1] = №, row[2] = Пан/Пані, row[3] = Σ, row[4] = І, row[5] = % | |||
if #row >= 5 then | |||
local player_cell = clean_wikilinks(row[2]) | |||
if | if player_cell == player_name then | ||
return { | return { | ||
place = mw.text.trim( | place = mw.text.trim(row[1]), | ||
points = mw.text.trim( | points = mw.text.trim(row[3]), | ||
games = mw.text.trim( | games = mw.text.trim(row[4]), | ||
winrate = mw.text.trim( | winrate = mw.text.trim(row[5]) | ||
} | } | ||
end | end | ||