mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-12 23:54:53 +09:00
Player statistics move out of exp_legacy into their own plugin, with the totals kept on the controller instead of the PlayerData datastore, which was never synced anywhere. The lua module tracks the same statistics with the same rules. Gains are kept per player as unsent in storage and sent over IPC every 5 minutes for every player with changes, and for one player when they leave. Sent values move into the totals the controller gave when the player joined, so get() is the total on every server either way. Nothing is resent. The instance plugin sends everything left when the server stops and drops anything unsent when it starts. A leftover can only come from a save made before it was sent, such as the autosave loaded after a crash, so dropping it loses a few minutes at worst but never counts twice. The controller adds the deltas to a record per player name in database/exp_statistics/players.json. Instances fetch a player's totals on join and hand them to lua over rcon. The web UI gets a sortable table of every player at /exp_statistics, behind exp_statistics.view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.2 KiB
Lua
51 lines
2.2 KiB
Lua
--[[-- ExpStatistics - Config
|
|
Which statistics are tracked, and the order they are shown in.
|
|
]]
|
|
|
|
local e = defines.events
|
|
return {
|
|
MapsPlayed = true, -- Maps a player has joined at least once
|
|
Playtime = true, -- Minutes online
|
|
AfkTime = true, -- Minutes online after doing nothing for 5 minutes
|
|
DistanceTravelled = true, -- Tiles moved while not afk
|
|
MachinesRemoved = true, -- Own force entities marked for deconstruction or mined
|
|
TreesDestroyed = true, -- Trees marked for deconstruction or mined
|
|
OreMined = true, -- Resources mined by hand
|
|
DamageDealt = true, -- Damage to entities not on the same force or neutral
|
|
Kills = true, -- Entities killed which are not on the same force or neutral
|
|
RocketsLaunched = true, -- Counted for every online player on the force
|
|
ResearchCompleted = true, -- Counted for every online player on the force
|
|
--- Statistics that go up by one each time the event is raised for a player
|
|
--- @type table<string, defines.events>
|
|
counters = {
|
|
MachinesBuilt = e.on_built_entity,
|
|
MapTagsMade = e.on_chart_tag_added,
|
|
ChatMessages = e.on_console_chat,
|
|
CommandsUsed = e.on_console_command,
|
|
ItemsPickedUp = e.on_picked_up_item,
|
|
TilesBuilt = e.on_player_built_tile,
|
|
ItemsCrafted = e.on_player_crafted_item,
|
|
DeconstructionPlannerUsed = e.on_player_deconstructed_area,
|
|
Deaths = e.on_player_died,
|
|
JoinCount = e.on_player_joined_game,
|
|
TilesRemoved = e.on_player_mined_tile,
|
|
CapsulesUsed = e.on_player_used_capsule,
|
|
EntityRepaired = e.on_player_repaired_entity,
|
|
},
|
|
--- The order statistics are shown in, disabled ones are skipped
|
|
display_order = {
|
|
"Playtime", "AfkTime",
|
|
"MapsPlayed", "JoinCount",
|
|
"ChatMessages", "CommandsUsed",
|
|
"RocketsLaunched", "ResearchCompleted",
|
|
"MachinesBuilt", "MachinesRemoved",
|
|
"TilesBuilt", "TilesRemoved",
|
|
"TreesDestroyed", "OreMined",
|
|
"ItemsCrafted", "ItemsPickedUp",
|
|
"Kills", "Deaths",
|
|
"DamageDealt", "DistanceTravelled",
|
|
"CapsulesUsed", "EntityRepaired",
|
|
"DeconstructionPlannerUsed", "MapTagsMade",
|
|
},
|
|
}
|