This section is for those users that have been given access to the Steam API for publishing your game to that platform. To be able to use these functions you must have been accepted onto Steam previously, either through a publisher or through the Greenlight system, and have set up the Steam Preferences and the Steam Game Options correctly.
There are a great number of different functions related to the Steam API, and so we've split them up into the following sections to make it easier to navigate:
The following set of functions are all for checking the availability of certain aspects of the Steam client or server API, and as such return either true or false depending on factors like the server being busy or the user being logged on etc... This means that these functions should be used before any other function call to ensure that the client/server setup is correct and communicating with your game:
The following functions can be used to get the app (game) ID and the account ID for the current user, which can then be used in other functions relating to Steam and the Steam Workshop:
The Steam Overlay is the visual display that can be brought up to display the Steam interface to the user. This is normally done by the user themselves using a combination of keys, but you also have the possibility of doing it from within your game, so that you can map a button or an event to show the overlay, using the following functions:
The Steam API supports persistent leaderboards with automatically ordered entries. These leaderboards can be used to display global and friend leaderboards in your game and on the community web page for your game. Each game can have up to 10,000 leaderboards, and each leaderboard can be retrieved immediately after a player's score has been inserted into it, but note that for each leaderboard, a player can have only one entry, although there is no limit on the number of players per leaderboard.
Each leaderboard entry contains a name, a score and a rank for the leaderboard, and this data will be replaced when a new leaderboard entry is created for the user, and the following functions can be used to add and retrieve this data form the leaderboards for your game:
The Steam Stats and Achievements API provides an easy way for your game to provide persistent, roaming achievement and statistics tracking for your users. The user's data is associated with their Steam account, and each user's achievements and statistics can be formatted and displayed in their Steam Community Profile.
In addition to providing highly-valued rewards to players of your games, achievements are useful for encouraging and rewarding teamwork and player interaction, providing extra dimensionality to the game objectives, and rewarding users for spending more of their time in-game, and as such it is recommended that your game has a few. They are easily set up from the Steam Dashboard, but will require that you create special Icons for them.
Statistics track fine-grained pieces of information, such as play time, number of power-ups used, etc. You may choose to use them simply for tracking internal game data - so that, for instance, you can grant an achievement based on multi-session game-play statistics collected from the user across multiple computers. Or, you can track interesting game data for display on the user's Steam Community page, where users can compare their own stats against their friends.
Statistics come in three types, integers, floats and averages, and GameMaker Studio 2 permits you to modify each of these from your game, but they should have been initialised previously from the Steamworks control panel for your game.
NOTE: You must wait until steam_stats_ready has returned true, before attempting to read or write stats and achievements.
Further details and instructions on how to use statistics and achievements can be found in the following pages describing the functions:
- steam_set_achievement
- steam_get_achievement
- steam_clear_achievement
- steam_set_stat_int
- steam_set_stat_float
- steam_set_stat_avg_rate
- steam_get_stat_int
- steam_get_stat_float
- steam_get_stat_avg_rate
- steam_reset_all_stats
- steam_reset_all_stats_achievements
If the user in Offline Mode, Steam keeps a local cache of the stats and achievement data so that the APIs can be use as normal. Any stats unable to be committed are saved for the next time the user is online. In the event that there have been modifications on more than one machine, Steam will automatically merge achievements and choose the set of stats that has had more progress. Because Steam keeps a local cache of stats data it is not necessary for the game to also keep a local cache of the data on disk, especially as such caches often come in conflict and when they do it looks to a users as if their progress has been reverted, which is a frustrating experience.
The Steam Cloud provides an easy and transparent remote file storage system for your game. All files written to disk using the GameMaker Studio 2 cloud functions (listed below) will be replicated to the Steam servers after the game exits. If the user then changes computers, the files will then be downloaded to the new computer before the game launches, meaning that the game can then access the files by reading them using the appropriate Steam functions. The Steam Client does the work of ensuring that the files are kept synchronized across all computers the user may be accessing.
NOTE: By default, the Cloud is not enabled for a game on Steamworks. it must be enabled previously from the 'Cloud' tab of the Steamworks game admin, where you should set the byte and file quota. The next time you publish your games Steamworks configuration, the Cloud storage will be ready to use.
The following functions can be used to access the Steam Cloud from within GameMaker Studio 2
Steam supports both free and paid downloadable content (DLC), and in the Steam client, a game with downloadable content appears as a single application in the user's game list with the downloadable content viewable through the games properties dialog. Once owned, downloadable content is treated as an integral part of the game and Steam will automatically update the content when a patch is available and installs the content when the user installs the game.
Since this is all handled by the Steam servers and the configuration of any DLC is done through the Steamworks control panel, there are only a few functions necessary in GameMaker Studio 2 to check for this extra content:
The Steam API integration in GameMaker Studio 2 permits the sharing of certain user-generated content. You can use them to share files to the Steam Workshop for your game, as well as post screen shots to the user profile.
Finally, you also have available a great number if UGC functions for working with Workshop files and other user content features, which you can find listed in the following section of the manual: