Модуль:FetchData: відмінності між версіями
Admin (обговорення | внесок) (Створена сторінка: local p = {} function p.season_result(frame) local season = frame.args.season local player = frame.args.player local title = mw.title.makeTitle(0, "Перший_сезон") -- change based on season argument local content = title:getContent() -- Find the player's row and extract the place local pattern = "|%s*" .. player .. "%s*|%s*%d+%s*|" local start_pos, end_pos = string.find(content, pattern) if not start_pos then...) |
(Немає відмінностей)
|
Версія за 14:32, 17 квітня 2024
Документацію для цього модуля можна створити у Модуль:FetchData/документація
local p = {}
function p.season_result(frame)
local season = frame.args.season
local player = frame.args.player
local title = mw.title.makeTitle(0, "Перший_сезон") -- change based on season argument
local content = title:getContent()
-- Find the player's row and extract the place
local pattern = "|%s*" .. player .. "%s*|%s*%d+%s*|"
local start_pos, end_pos = string.find(content, pattern)
if not start_pos then
return "Data not found"
end
-- Extract the rank from the row
local rank_pattern = "|%s*(%d+)%s*|"
local rank = string.match(string.sub(content, start_pos, end_pos), rank_pattern)
return rank or "Rank not found"
end
return p