• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Steam Achievements - any step by steps guides?

DigiChain

Member
I'm looking to add some Steam achievements to my game, but can't seem to find any simple (step by step) guides on exactly what code I need to run in my game and where.

Can I simply just use this code at the appropriate point to set achievements (without doing anything else beforehand):
if !steam_get_achievement("Achievement") steam_set_achievement("Achievement");

Or do I need to be initialising Steam in some way first?
 

FrostyCat

Redemption Seeker
You should check whether the API is ready beforehand. This is clearly explained in the Manual's listings for Steam achievements and statistics functions:
The Manual said:
NOTE: You must wait until steam_stats_ready has returned true, before attempting to read or write stats and achievements.
Other than that, what you showed should be exactly how it's done. Pay attention to the examples at the bottom of each function entry.
 

DigiChain

Member
Thats great thanks!

So I'm curious where / how often do you run the steam_initialised / steam-stats_ready code?:

global.steam_api = false;

if steam_initialised()
{
if steam_stats_ready() && steam_is_overlay_enabled()
{
global.steam_api = true;
}
}


It would make sense to run it in the initial room, but if it were to fail then I'd need to continue rechecking throughout the game... or perhaps before each steam achievement. Wondering what best practice would be?
 

Khao

Member
If I remember correctly (been a while since I did all this), if you have steam set up properly (you installed the SDK, told Game Maker your AppID code, have the achievements set in steamworks and all of that nonsense), steam should automatically be initialized when you run your game while logged into Steam. If you got that down, then yes, that line of code will grant you the achievement.

Personally, I checked "if steam_initialised() && steam_stats_ready()" every time I wanted to add an achievement, and literally never again elsewhere.
 

DigiChain

Member
Personally, I checked "if steam_initialised() && steam_stats_ready()" every time I wanted to add an achievement, and literally never again elsewhere.
Yes, this would seem a more logical way of doing it, only checking steam is initialised at the point of actually using it. Thanks
 
Top