Module:Player: Difference between revisions
Appearance
Initialise player module. |
m Add null safety. |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
local player = mw.ext.MoonPlayerData | |||
if not player then | |||
return "Error: mw.ext.MoonPlayerData extension library is not loaded." | |||
end | |||
local id = tonumber(frame.args.id) | local id = tonumber(frame.args.id) | ||
if not id then return "Missing or invalid Player ID" end | |||
local info = player.getInfo(id) | local info = player.getInfo(id) | ||
| Line 50: | Line 54: | ||
label11 = "Playtime", | label11 = "Playtime", | ||
data11 = string.format("%.0f hours", info.play_time / 3600), | data11 = string.format("%.0f hours", (info.play_time or 0) / 3600), | ||
label12 = "Total Hits", | label12 = "Total Hits", | ||
Latest revision as of 08:47, 9 July 2026
Documentation for this module may be created at Module:Player/doc
local p = {}
function p.main(frame)
local player = mw.ext.MoonPlayerData
if not player then
return "Error: mw.ext.MoonPlayerData extension library is not loaded."
end
local id = tonumber(frame.args.id)
if not id then return "Missing or invalid Player ID" end
local info = player.getInfo(id)
if not info then
return "Player not found"
end
return frame:expandTemplate{
title = "Infobox",
args = {
title = info.name,
image = info.avatar_url,
label1 = "Country Code",
data1 = info.country_code,
label2 = "Joined Date",
data2 = info.joined_date,
label3 = "Status",
data3 = info.status,
label4 = "pp",
data4 = info.pp,
label5 = "Global Rank",
data5 = info.global_rank,
label6 = "Country Rank",
data6 = info.country_rank,
label7 = "Accuracy",
data7 = info.accuracy,
label8 = "Ranked Score",
data8 = info.ranked_score,
label9 = "Total Score",
data9 = info.total_score,
label10 = "Playcount",
data10 = info.play_count,
label11 = "Playtime",
data11 = string.format("%.0f hours", (info.play_time or 0) / 3600),
label12 = "Total Hits",
data12 = info.total_hits,
label13 = "Max Combo",
data13 = info.max_combo,
label14 = "Level",
data14 = info.level,
label15 = "Count SSH",
data15 = info.count_ssh,
label16 = "Count SS",
data16 = info.count_ss,
label17 = "Count SH",
data17 = info.count_sh,
label18 = "Count S",
data18 = info.count_s,
label19 = "Count A",
data19 = info.count_a,
}
}
end
return p