Command line utility for parsing detailed Steam stat information.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.7 KiB

2 years ago
2 years ago
  1. # Steam Stat Utils
  2. Command line utility for parsing detailed Steam stat information.
  3. ## Background
  4. `steam_stat_utils.py` fetches data primarily from two sources: the Steam client's local filesystem cache and the Steam Web API. With this information you can view global stats as well as signed-in users' stats.
  5. You can also dump raw data for local/offline playtesting, such as with [Goldberg Emulator](https://mr_goldberg.gitlab.io/goldberg_emulator/ "Goldberg Emulator"). Steam's copy of data can change over time and as your games receive major updates, so this process should be repeated regularly.
  6. ## Usage
  7. Usage details are in development and likely to change with future commits.
  8. `steam_stat_utils.py path/to/steam_dir appid [userid]`
  9. ## Requirements
  10. - Python 3.5 or higher
  11. - [vdf](https://github.com/ValvePython/vdf "vdf")
  12. ## Tested Configurations
  13. - Python 3.5.3 on Debian GNU/Linux (WSL)
  14. ## Planned Additions and Improvements
  15. 1. Reading/writing [average-rate](https://partner.steamgames.com/doc/features/achievements#AVGRATE "average-rate") type stats (currently treated the same as floating-point type)
  16. 2. Adding and improving usage parameters
  17. 3. Writing `achievements.json` file format used by Goldberg Emulator
  18. ## Limitations
  19. - Writing raw data back to Steam's local cache is not supported. If you want to manipulate your own player stats, look up Steam Achievement Manager.
  20. - The current version of Goldberg Emulator doesn't support achievements or global stats yet. To enable global stats support, I am using a custom build with the following changes (as of August 2019):
  21. 1. In `dll/local_storage.h` add the following preprocessor directive next to the other defines near the top of the file:
  22. ```
  23. #define GLOBALSTATS_STORAGE_FOLDER "globalstats"
  24. ```
  25. 2. In `dll/steam_user_stats.h` replace the two GetGlobalStat placeholder functions with these implementations:
  26. ```
  27. // Gets the lifetime totals for an aggregated stat
  28. bool GetGlobalStat( const char *pchStatName, int64 *pData )
  29. {
  30. PRINT_DEBUG("GetGlobalStat %s\n", pchStatName);
  31. if (!pchStatName || !pData) return false;
  32. std::lock_guard<std::recursive_mutex> lock(global_mutex);
  33. int read_data = local_storage->get_data(GLOBALSTATS_STORAGE_FOLDER, pchStatName, (char* )pData, sizeof(*pData));
  34. if (read_data == sizeof(int64))
  35. return true;
  36. return false;
  37. }
  38. bool GetGlobalStat( const char *pchStatName, double *pData )
  39. {
  40. PRINT_DEBUG("GetGlobalStat %s\n", pchStatName);
  41. if (!pchStatName || !pData) return false;
  42. std::lock_guard<std::recursive_mutex> lock(global_mutex);
  43. int read_data = local_storage->get_data(GLOBALSTATS_STORAGE_FOLDER, pchStatName, (char* )pData, sizeof(*pData));
  44. if (read_data == sizeof(int64))
  45. return true;
  46. return false;
  47. }
  48. ```