The Steamworks plugin allows integrating a project with Steam. It is currently supported with the Windows WebView2, macOS WKWebView and Linux CEF export options. (It does not support NW.js.)
The plugin provides basic access to the user details, the Steam Overlay, achievements and DLC.
Exporting for Steam
To test your game with Steam, export it with the Windows, macOS or Linux options. You must also have Steam installed and running on your system for the plugin features to work. Use the Is available condition to check if the plugin features are available.
For more details about getting your project running on Linux or the Steam Deck, see the guide Exporting to Linux and the Steam Deck.
During development, you must also set your Steam App ID in the plugin's App ID property, and check Development mode. This tells Steam your app ID. If Steam cannot determine the App ID it will fail to initialize and Is available will be false, so this is necessary during development to make sure Steam knows the app ID and enable Steam features. If you don't have an app ID yet, you can use the app ID 480, which is the ID for the Steamworks SDK sample "Space war".
Before publishing to Steam, be sure to uncheck Development mode, as when it is on it disables Steam's recommended "restart app if necessary" behavior.
Steam Overlay
The Steam Overlay currently works well on the Steam Deck. However the in-game overlay is not currently supported on Windows, macOS or Linux systems other than the Steam Deck. The reason for this is on these platforms the in-game overlay uses an intrusive design that modifies how the game application works (rather than displaying content over the app separately), but Steam doesn't know how to do this with the multi-process architecture of modern browser engines. However Steam has specially designed fallbacks for when the in-game overlay is not supported - usually this means it shows the actual Steam user interface rather than displaying content inside the game.
We've gone to great lengths to try to support the in-game overlay, but it appears to be impossible to work around the limitations of the way Steam currently works. The only way to get the in-game overlay to work on Windows, macOS and Linux is for Valve to change the way Steam works - and the more people who ask for it, the more likely they are to act. So if having the in-game overlay rather than fallbacks is important to you, try the following:
If it's feasible we will support it, but we need co-operation from Valve to get it working! Remember, the overlay works fine on the Steam Deck, as it uses a different design that displays content over the app separately.
Steam Cloud
You don't actually need the Steamworks plugin to use Steam Cloud - you can use Steam Auto-Cloud with Construct's File System plugin to automatically synchronize a folder of files between systems. See the Steam Cloud documentation for more details.
The root paths for Steam auto-cloud correspond to the known folder picker tags in the File System plugin like so:
- App Install Directory: "<app>"
- WinMyDocuments: "<documents>"
- WinAppDataLocal / LinuxXdgDataHome: "<local-app-data>"
- WinAppDataRoaming: "<roaming-app-data>"
- WinSavedGames: "<saved-games>"
- LinuxHome: "<profile>"
Further, the StaticAccountKey expression of the Steamworks plugin corresponds to the {64BitSteamID} variable in Steam Auto-Cloud special path values. Therefore you can set up File System to write to a folder that is set up for Steam Auto-Cloud. For example on Windows you could do the following:
- Set up Steam Auto-Cloud to sync the root WinMyDocuments, path mygame/{64BitSteamId}
- Use File System to read/write to picker tag "<documents>", folder path "mygame/" & Steam.StaticAccountKey & "/file.json"
Now file.json is in the Steam Auto-Cloud folder and so Steam should sync that across different devices when closing/launching your game.
Script interface
The Steamworks plugin exposes the following APIs that can be used from JavaScript code.
- isAvailable
- Boolean indicating if Steam features are available.
- isRunningOnSteamDeck
- Boolean indicating if the game is currently running on a Steam Deck device.
- personaName
- A string of the current user's Steam persona (display) name.
- accountId
- The current user's Steam account ID as a number.
- staticAccountKey
- The current user's Steam static account key as a string. Note this is a string as it may exceed the range of JavaScript numbers.
- playerSteamLevel
- Number representing the Steam level of the user, as shown on their Steam community profile.
- appId
- The current Steam app ID as a number.
- steamUILanguage
- currentGameLanguage
- Strings representing the current language setting for both the Steam user interface and the current game, as reported by Steam.
- getAvailableGameLanguages()
- Returns an array of strings representing available languages.
- showOverlay(optionStr)
- Request to show the Steam overlay, passing a string of the information to show, which must be one of
"friends"
, "community"
, "players"
, "settings"
, "official-game-group"
, "stats"
, "achievements"
.
- showOverlayURL(url, modal)
- Request to show the Steam overlay showing a web page at the given URL (string). This can optionally be made modal by passing
true
for the modal parameter.
- async unlockAchievement(achievement)
- Request to unlock an achievement specified by a string. Returns a Promise that resolves with a boolean, which is true if the operation completed successfully or false if it failed.
- async clearAchievement(achievement)
- Request to clear (reset) an achievement specified by a string. Returns a Promise that resolves with a boolean, which is true if the operation completed successfully or false if it failed.
- async checkDlcInstalled(appIdArray)
- Check if DLC is installed, passing an array of app IDs to check (as this method is asynchronous, this allows for checking multiple app IDs in one call). Returns a Promise that resolves with a boolean, which is true if the operation completed successfully or false if it failed. After it completes successfully,
isDlcInstalled()
can be called to synchronously check the result of individual app IDs.
- isDlcInstalled(appId)
- Returns a boolean indicating if the specified DLC (given by an app ID) is installed. This is synchronous but can only be used after
checkDlcInstalled()
passing the same app ID has completed successfully.
- installDlc(appId)
- uninstallDlc(appId)
- Request to initiate installation or uninstallation of DLC specified by an app ID.