This mod adds player stats. By default it logs the number of digged and placed nodes, the number of deaths and the played time for each player. It also has an API to make it easy for other mods to add new stats (see below). The stats can be printed with the /stats <playername> command.
This is a side-product of a game that I work on currently.
Depends:
Nothing.
License:
GPL
GitHub:
https://github.com/PilzAdam/stats
Download:
https://github.com/PilzAdam/stats/archive/master.zip
The API:
To add new stats to your mod you first need to add a softdepend on stats (that means your mod will still work without the stats mod!):
Add this to your depends.txt:
Code: Select all
stats?
Code: Select all
if stats then
-- Register the stat, so its printed in the /stats command
stats.register_stat({
name = "my_new_stat",
description = function(value)
return " - My feature was used " .. value .. " times by the player"
end,
})
-- To increase the stat (e.g. when the player digs a node):
-- player can be either the object, or the playername as string
stats.increase_stat(player, "my_new_stat", 1)
-- or to set it to a different value:
stats.set_stat(player, "my_new_stat", 1337)
-- and to read a stat use:
stats.get_stat(player, "my_new_stat")
end
If you run this mod on your server, and you really care about performance, then you can change the value in line 151 to something higher (like 10 or so), to remove some load from the server. This shouldnt change too much, just added it in case you run a server on a Rasberry PI with 100 players.
Mods that support the stats mod:
Your mod could be here! Post in this topic if you have added support to it.