Implementing Steam achievements?

  • #20, by afrlmeThursday, 13. July 2017, 21:12 7 years ago
    I don't think you need to copy the entire script into your execute a script mate. It was syntax.
    setSteamAchievement("STEAM_ACHIEVEMENT_CHAPTER_1") -- set achievement to true

    The flags bit is for resetting the achivement. By default it's false so not needed. If you are wanting to test whether the game is triggering the achievement when the achievement goal is met, then you might want to reset your achievements using the flag...
    setSteamAchievement("STEAM_ACHIEVEMENT_CHAPTER_1", flags=1, clear = true})

    Anyway, hopefully this makes some sense now.

    Imperator

    7278 Posts


  • #21, by smac96Thursday, 13. July 2017, 21:55 7 years ago
    Thanks AFRLme, but it still doesn't work.

    Do I need to add more code somewhere else?

    Or should be enough to only add this script when the achievement needs to be unlocked?

    setSteamAchievement("STEAM_ACHIEVEMENT_CHAPTER_1")

    Newbie

    97 Posts

  • #22, by sebastianThursday, 13. July 2017, 22:05 7 years ago
    im not sure if it matters, but in the wiki there is this mentioned:

    Note: this command only works if the steam_api library was loaded and if a steam account for your game exists.

    does the console outputs anything like "steam api loaded" or something like that? 

    Not sure how this works, but I miss the connection to steam here.... (or does it magically work because of the .dll/.so/.dylib files ?

    Thread Captain

    2346 Posts

  • #23, by smac96Thursday, 13. July 2017, 22:27 7 years ago
    The file "steam_api.dll" is in the same folder where the game is.

    I sent the build of the game to SteamWorks, so I can see it on my Steam client library and launch the game from there.

    Do I need a code to "enable" or "load" the steam api when the game starts?

    Newbie

    97 Posts

  • #24, by afrlmeThursday, 13. July 2017, 23:22 7 years ago
    Are you sure steam Achievements were available in 3.7 & not only in 3.7.1? I'm not sure when they were implemented to be honest & Simon or David overhauled the way it works for VS 4.x.

    By the way you can query if steam is initialized like so...
    if getProperty("steam_initialized") then
     -- add some lines of code here
    end


    Alternatively if you would prefer to use a condition you have created in the editor then you could do something like this...
    1. create a condition & name it "steam_initialized"
    2. inside of the at start of game actions bit in the main game tab create an execute a script action & add this to it.
    getObject("Conditions[steam_initialized]"):setValue( VConditionValue, getProperty("steam_initialized") )

    & this will set the condition to true or false, which you will now be able to use for creating if condition based queries in the editor if you don't want to use the getProperty bit inside of each execute a script.

    As for Steam & the dll. I think you just need to have the steam.dll file associated with the game in the root folder where the executable is located & it should take care of the rest itself. That's about as much as I know as I've not had first hand experience of releasing a game on Steam myself yet, but you could ask JoeRichardson who made Four Last Things & The Preposterous Awesomeness of Everything or you could try asking Jacob (Dilated) who made Paradigm, as all of those games have steam achievements implemented.

    * edit: seems the old Steam functions still exist on the wiki. According to this, the functions have existed since 3.6. Technically they should work, just fine.

    Personally I would recommend making a copy of your ved file, upgrading to 4.2.5 & testing the copy of the ved file you just made in that to see if your game works correctly. You will however have to update the steam achievement & stat functions though as they were replaced in 4.x due to them now also covering achievements & stats for GOG Galaxy application too.

    Imperator

    7278 Posts

  • #25, by sebastianFriday, 14. July 2017, 07:43 7 years ago
    the getProperty function is available since 4.1 so thisbwill not work here i guess. 

    Thread Captain

    2346 Posts

  • #26, by smac96Friday, 14. July 2017, 09:15 7 years ago
    Thanks guys, but it still doesn't work.
      
    I'm wondering if in the Steam client is it possible to unlock achievements for test purposes also if the game is not yet released.

    Maybe is simply this the problem? It can be that I'm expecting a "pop-up message" when the achievement is unlocked but it doesn't show simply because the Steam client doesn't allow me to see it until the game is going to be public released?

    In this case, how can I test and be sure that the achievement will be unlocked correctly?

    Newbie

    97 Posts

  • #27, by afrlmeFriday, 14. July 2017, 12:13 7 years ago
    the getProperty function is available since 4.1 so thisbwill not work here i guess. 

    No mate, the getProperty function has been available since before that. It's likely referring to something that was added. The available since bit is wrong because I actually hand wrote those pages myself before I knew they would get overwritten automatically by the devs via something they implemented in the engine. What I did on each of those pages was create a table that said: "x available since version?, y available since version?" & so on.

    Command History
    Available since v3.7
    system_language property added to v3.8


    steam_initialized already existed. platform already existed. galaxy_initialized was added in 4.x & I believe there used to be a resolution parameter that was added in 4.x as well for returning the monitor resolution, but that might have been removed?

    @smac96: I know Jacob was testing achievements before paradigm was publicly released as I vaguely recalling him asking me how to reset them. Maybe you have to play it as a beta? There should be an option for uploading beta version to Steam I think? Alternatively you could query if the achievement is unlocked with the getSteamAchievement() function.
    print( "name of achievement", getSteamAchievement("name of achievement") )

    Should print out "name of achievement, true or false" to the messages.log file.

    Also quick question: are you sure you are using the correct names for the achievements? I'm pretty sure they will be case senstive just like object names & character names etc are in VS.

    Imperator

    7278 Posts

  • #28, by smac96Sunday, 16. July 2017, 12:45 7 years ago
    So, maybe I'm a step closer to it. Here are my tests:

     
    • I added the following script associated to the key button "1" in order to know if Steam has been found or not: 

    if getProperty("steam_initialized") then
    print("STEAM HAS BEEN FOUND!")
    else
    print("NO STEAM FOUND!")
    end

    and when I execute it, on the message log I have the following result:

    12:27:32: Error: Failed to run string in Lua: [string "if getProperty("steam_initialized") then ..."]:1: attempt to call global 'getProperty' (a nil value)
    12:27:32: Error: String content: if getProperty("steam_initialized") then
    print("STEAM HAS BEEN FOUND!")
    else
    print("NO STEAM FOUND!")
    end

    What's wrong in this code?


    • Then I added the following script associated to the key button "2" in order to know what is the current state of the achievement:

    print( "STEAM_ACHIEVEMENT_CHAPTER_1", getSteamAchievement("STEAM_ACHIEVEMENT_CHAPTER_1") ) 

    and when I execute it, on the message log I have the following result:

    12:28:24: STEAM_ACHIEVEMENT_CHAPTER_1 false


    • Finally I added the following script associated to the key button "3" in order to unlock the achievement: 

    setSteamAchievement("STEAM_ACHIEVEMENT_CHAPTER_1")

    but when I execute it, nothing appears on the message log. When I press the button "2" again to know what is the current state of the achievement, the result is that the state of the achievement is still FALSE.

    Newbie

    97 Posts

  • #29, by afrlmeSunday, 16. July 2017, 13:59 7 years ago
    Thing is that it's possible that steam api/library dll thing has changed since 3.6, which is possibly why the engine is having difficulty working. I really do recommend upgrading to a newer version of the editor - like I said, 4.x has new functions for handling steam/gog achievements & stats. Maybe the internal engine source code is different too, but I could be wrong; my knowledge of implementing Steam stuff is very limited as I've not had first hand experience yet. About the only person that can help you with this is SimonS probably. Try sending him a PM the morrow.

    Imperator

    7278 Posts

  • #30, by sebastianSunday, 16. July 2017, 14:05 7 years ago
    i remember that something changed in steam api over the last 2(?) years...

    Thread Captain

    2346 Posts