Steam API

This section shows the functions associated with the Steam API.

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 Global Game Settings correctly.

Checking Steam Client/Server

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:

  1. steam_initialised
  2. steam_stats_ready
  3. steam_is_overlay_enabled
  4. steam_get_persona_name
  5. steam_get_user_persona_name
  6. steam_get_user_steam_id
  7. steam_is_user_logged_on

General API Functions

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:

  1. steam_get_app_id
  2. steam_get_user_account_id
  3. steam_current_game_language
  4. steam_available_languages

The Steam Overlay

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:

  1. steam_activate_overlay
  2. steam_activate_overlay_browser
  3. steam_activate_overlay_store
  4. steam_activate_overlay_user
  5. steam_is_overlay_activated

Leaderboards

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:

  1. steam_create_leaderboard
  2. steam_upload_score
  3. steam_upload_score_buffer
  4. steam_download_scores
  5. steam_download_scores_around_user
  6. steam_download_friends_scores

Achievements and Statistics

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 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:

  1. steam_set_achievement
  2. steam_get_achievement
  3. steam_clear_achievement
  4. steam_set_stat_int
  5. steam_set_stat_float
  6. steam_set_stat_avg_rate
  7. steam_get_stat_int
  8. steam_get_stat_float
  9. steam_get_stat_avg_rate
  10. steam_reset_all_stats
  11. 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.

Cloud Functions

The Steam Cloud provides an easy and transparent remote file storage system for your game. All files written to disk using the GameMaker: Studio 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

  1. steam_is_cloud_enabled_for_app
  2. steam_is_cloud_enabled_for_account
  3. steam_get_quota_total
  4. steam_get_quota_free
  5. steam_file_exists
  6. steam_file_size
  7. steam_file_persisted
  8. steam_file_write
  9. steam_file_write_file
  10. steam_file_read
  11. steam_file_share
  12. steam_file_delete

User Generated Content

The Steam API integration in GameMaker: Studio 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.

  1. steam_is_screenshot_requested
  2. steam_send_screenshot

Apart from these basic screenshot functions, 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:

  1. User Generated Content

Finally there is a legacy function, which is now deprecated and should not be used, but it is still supported for those games that used it originally (although you should change and update to the new UGC functions as soon as possible):

  1. steam_publish_workshop_file

DLC

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 to check for this extra content:

  1. steam_user_owns_dlc
  2. steam_user_installed_dlc


Back: Contents
© Copyright YoYo Games Ltd. 2018 All Rights Reserved