Appearance
Steamworks API
Full Steam integration for your game.
PRO FEATURE
Steamworks integration requires GemShell Pro.
Access via the global steam object in your game code.
Setup
- Enable Steamworks in GemShell settings
- Enter your Steam App ID
- Build your game
Initialization
Steam initializes automatically. Check availability:
javascript
// Check if Steam is available
if (typeof steam !== 'undefined' && await steam.isAvailable()) {
// Steam features available
const name = await steam.getPersonaName();
console.log(`Hello, ${name}!`);
}Available APIs
| API | Description |
|---|---|
| User Info | Player data, Steam ID, Friends, Avatars |
| Achievements | Unlock/query achievements, Stats |
| Cloud Saves | Steam Cloud storage |
| Leaderboards | Global leaderboards |
| Lobbies & P2P | Multiplayer lobbies, P2P networking |
| Rich Presence | "Playing..." status |
| Overlay | Steam Overlay |
| Utils & DLC | Platform info, DLC, Workshop |
Quick Examples
Get Player Info
javascript
const steamId = await steam.getSteamID();
const name = await steam.getPersonaName();
const level = await steam.getPlayerSteamLevel();Unlock Achievement
javascript
await steam.unlockAchievement('FIRST_BOSS');
await steam.storeStats();Save to Cloud
javascript
const saveData = JSON.stringify(gameState);
await steam.fileWrite('save.json', saveData);Load from Cloud
javascript
if (await steam.fileExists('save.json')) {
const data = await steam.fileRead('save.json');
gameState = JSON.parse(data);
}Set Rich Presence
javascript
await steam.setRichPresence('status', 'Fighting the Dragon');
await steam.setRichPresence('level', '42');Submit Leaderboard Score
javascript
const board = await steam.findLeaderboard('HighScores');
if (board) {
await steam.uploadLeaderboardScore(board, score);
}Callbacks
Call runCallbacks() regularly to process Steam events:
javascript
// In your game loop
function update() {
if (typeof steam !== 'undefined') {
steam.runCallbacks();
}
// ... rest of game update
}Testing
For development, Steam uses App ID 480 (Spacewar) by default.
To test with your own App ID:
- Set your App ID in GemShell
- Have the game in your Steam library
- Run Steam in the background
Feature Detection
javascript
async function initSteam() {
if (typeof steam === 'undefined') {
console.log('Steam not available');
return false;
}
if (!await steam.isAvailable()) {
console.log('Steam not running');
return false;
}
console.log('Steam initialized');
return true;
}