Steam Achievements - any step by steps guides?

Discussion in 'Game Design, Development And Publishing' started by DigiChain, Aug 15, 2019.

  1. DigiChain

    DigiChain Member

    Joined:
    Jan 24, 2018
    Posts:
    36
    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?
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,429
    You should check whether the API is ready beforehand. This is clearly explained in the Manual's listings for Steam achievements and statistics functions:
    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.
     
  3. DigiChain

    DigiChain Member

    Joined:
    Jan 24, 2018
    Posts:
    36
    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?
     
  4. Khao

    Khao Member

    Joined:
    Jun 22, 2016
    Posts:
    150
    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.
     
  5. DigiChain

    DigiChain Member

    Joined:
    Jan 24, 2018
    Posts:
    36
    Yes, this would seem a more logical way of doing it, only checking steam is initialised at the point of actually using it. Thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice