Steam Achievements Issue

CellStudios

and team member
Game Developer
Aug 3, 2019
778
2,807
Hey all,

I was wondering if I could get a little assistance. For some reason my achievements aren't working on my game.

When people load up the game for the 1st time, they get 87% of achievements unlocked and I'm not sure why.

Now this doesn't happen for everyone, the odd 1% of people don't get all the achievements, but the vast majority do.

I'm using this code to grant the achievements:

$ achievement.grant("achievment_name")
$ achievement.sync()

The very first achievements code is a little different, I read somewhere that you need to register the first achievement but now I can't find the article about that:

$achievement.grant("achievment_name")
init:
$achievement.register("achievment_name")
$achievement.sync()
$achievement.sync()

( please note, not all achievments are called "achievment_name", just changed it to that for the purpose of this ).

I'm heading off to bed now so if I don't reply, tis 'cause I'm sleeping :p Any help is much appreciated though.
 

noping123

Well-Known Member
Game Developer
Jun 24, 2021
1,716
2,723
Did you set them up properly in steamworks?

My achievements seem to be working fine - when I was setting it all up I saw all sorts of conflicting info so I did the following:

in my variables script (variables.rpy!) I just have an init section where I registered every single achievement.

Then whenever the achievement is supposed to pop:

if not achievement.has("achievement_name"):
$achievement.grant("achievement.name")
$achievement.sync()



That's literally all I did, and I have had no issues. (The only reason I did the if not bit is because I wasn't sure how it would interact trying to give the same achievement over and over - so I erred on the side of caution). granted my game has only been live for a few hours, but it seems to be working relatively ok so far. Most of the "hard" achievements have almost no completion, while the easy ones have pretty high completion. Seems about right - and everything worked correctly in my initial testing as well.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,966
16,214
Most of the "hard" achievements have almost no completion, while the easy ones have pretty high completion. Seems about right - and everything worked correctly in my initial testing as well.
Just a reminder that with Ren'Py achievements can not be used for personal statistics.

I'll not say how, because despite being grumpy I'm a good guy, but it's relatively easy to have the achievements list and to trigger them manually.



As for OP issue, achievements are also stored in the persistent file. Therefore, if the they were already in the pre-rewrite version, players will benefit from the ones they already had before the rewrite. This to the exception of the few that did some cleaning on their computer, or changed it.

The best way to deal with this issue would have be to add a flag into the game, and force a cleaning of the achievements:
Python:
init python:
    if persistent.achievementReset is None:
         achievement.clear_all()
         persistent.achievementReset = True
Like it rely on a persistent value, it can be done at init time, and since it's a flag, it will be done only once.

But it's a bit late now, since it would force the players to restart again, in order to benefit from the achievements they received in the rewrote episodes.
 

CellStudios

and team member
Game Developer
Aug 3, 2019
778
2,807
Did you set them up properly in steamworks?

My achievements seem to be working fine - when I was setting it all up I saw all sorts of conflicting info so I did the following:

in my variables script (variables.rpy!) I just have an init section where I registered every single achievement.

Then whenever the achievement is supposed to pop:

if not achievement.has("achievement_name"):
$achievement.grant("achievement.name")
$achievement.sync()



That's literally all I did, and I have had no issues. (The only reason I did the if not bit is because I wasn't sure how it would interact trying to give the same achievement over and over - so I erred on the side of caution). granted my game has only been live for a few hours, but it seems to be working relatively ok so far. Most of the "hard" achievements have almost no completion, while the easy ones have pretty high completion. Seems about right - and everything worked correctly in my initial testing as well.
Ah, I don't think we have anything in our code that actually registers the achivement :unsure: I'll look into that, cheers :)

Just a reminder that with Ren'Py achievements can not be used for personal statistics.

I'll not say how, because despite being grumpy I'm a good guy, but it's relatively easy to have the achievements list and to trigger them manually.



As for OP issue, achievements are also stored in the persistent file. Therefore, if the they were already in the pre-rewrite version, players will benefit from the ones they already had before the rewrite. This to the exception of the few that did some cleaning on their computer, or changed it.

The best way to deal with this issue would have be to add a flag into the game, and force a cleaning of the achievements:
Python:
init python:
    if persistent.achievementReset is None:
         achievement.clear_all()
         persistent.achievementReset = True
Like it rely on a persistent value, it can be done at init time, and since it's a flag, it will be done only once.

But it's a bit late now, since it would force the players to restart again, in order to benefit from the achievements they received in the rewrote episodes.
Only the rewrite has had achivements but since releasing on steam, we've had issues with episode 1 and 2 but was never able to fix it ( we added the clear achievements in the menu so people could manually do it ), but it meant having to restart the game every single time to get all achievements and it's a damn ballache.
 

Spin256

Mothers and Daughters
Game Developer
Dec 16, 2019
544
1,070
When people load up the game for the 1st time, they get 87% of achievements unlocked and I'm not sure why.
As has been mentioned, achievements are stored in the persistent file. If you don't delete persistent before building the project it can trigger the achievements on the game launch.

I find an easy way is to exclude the saves folder from the build.

Code:
build.classify('game/saves/**', None)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,966
16,214
As has been mentioned, achievements are stored in the persistent file. If you don't delete persistent before building the project it can trigger the achievements on the game launch.
I took a, really quick, look at his game, and the save folder isn't there.

This said, everything can still depend on how and where he grant the achievements. Since the persistent file isn't cleared from the previous play data, if there's an "unlockAchievements" label or function by example, the said previous data can possibly trigger achievements that haven't been unlocked during this play.
 

Iskender

Hello! I am creating...
Game Developer
Aug 1, 2017
638
812
Hello, could you help with setting the achievements. I set some achievements on steam but don't know where to set them in the game. should I make them happen in the game script files. If so could you give me the code for setting it up.
 

CellStudios

and team member
Game Developer
Aug 3, 2019
778
2,807
Hello, could you help with setting the achievements. I set some achievements on steam but don't know where to set them in the game. should I make them happen in the game script files. If so could you give me the code for setting it up.
In you options.rpy file you'll need to add this line:

Code:
define config.steam_appid = APP_ID
You can find your add ID on steam.

Then you'll need:

Code:
$achievement.grant("achievement_name")
    init:
        $achievement.register("achievement_name")
        $achievement.sync()
    $achievement.sync()
When you create an achievement in steamworks, you'll see it has an "API Name" ( basically what you choose to call the achievement ) and that's what you'll put in the "achievement_name" section.

That should be all you need.
 

Iskender

Hello! I am creating...
Game Developer
Aug 1, 2017
638
812
That should be all you need.
For some reason I can't achieve my own achievements XD
This is my options renpy
You don't have permission to view the spoiler content. Log in or register now.
and this is where I put the achievement
You don't have permission to view the spoiler content. Log in or register now.
But it doesn't pop up when I play that scene. Can anyone please help?
 

CellStudios

and team member
Game Developer
Aug 3, 2019
778
2,807
For some reason I can't achieve my own achievements XD
This is my options renpy
You don't have permission to view the spoiler content. Log in or register now.
and this is where I put the achievement
You don't have permission to view the spoiler content. Log in or register now.
But it doesn't pop up when I play that scene. Can anyone please help?
Coding looks fine, did you make the achievements on the steamworks site too and double checked the names matched up?
 

CellStudios

and team member
Game Developer
Aug 3, 2019
778
2,807
I'm uploading buld's directly as zip (standard) maybe I'm doing that wrong
I upload them as zips too, but steam has been having issues with zip uploads recently, I reached out to them and they said they're aware of the issue but no idea how long it'll take to fix.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,966
16,214
[...] and this is where I put the achievement [...]
Oh god... Sorry, but it's a really horrible code.

  1. The content of a label block SHOULD always be indented ;
  2. There's an init python block, that avoid the need to prefix all its line with "$" ;
  3. An init block SHOULD not be placed randomly, especially inside what happen to be a none indented label block ;
  4. As you wrote it, the line 45, and whatever follow at this level of indentation, isn't anymore part of the previous label block, but part of an anonymous block.

It works (yet not totally sure since you've issue with the achievement) due to the way Ren'Py is designed.
But this is a side effect and not a desired feature. Therefore, there's no guaranty that it will still works in the future ; future that can happen never, in years, or tomorrow.

Plus, correctly structuring your code, with the correct indentation and without putting init level content (among others, init blocks, screen declaration, ATL declaration, default, define and image statements) help to the visibility, and to find what you are currently searching when you need to fix a bug. Therefore it help to provide a bug free content and lower a bit the time needed to code your game.