Steam achievements bug

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
dragondatingsim
Regular
Posts: 115
Joined: Sat Feb 14, 2015 10:22 am
Tumblr: angelswithscalywings
Contact:

Steam achievements bug

#1 Post by dragondatingsim »

Apparently, there is a bug in our game that triggers a ton of steam achievements to be unlocked when someone quits the game from the menu. However, there is nothing in the code that suggests how/why this would happen.

We use our own in-game achievement system that works properly. It's just that Steam achievements apparently get activated when they shouldn't. The lines of code that activate steam achievements are only with lines that also activate the same achievements in our own in-game system.

Actually playing to a part that gets an achievement works properly - the achievement is unlocked on Steam and our own in-game system, but quitting the game apparently sometimes triggers a lot of steam achievements to be unlocked at once (15-30).

Anyone have any idea why this could be happening?

User avatar
PyTom
Ren'Py Creator
Posts: 16097
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Steam achievements bug

#2 Post by PyTom »

Can you post your code? The Ren'Py achievement's code is very simple (check common/00achevements.rpy), so this is more likely to be a bug in your code than in Ren'Py's support.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
dragondatingsim
Regular
Posts: 115
Joined: Sat Feb 14, 2015 10:22 am
Tumblr: angelswithscalywings
Contact:

Re: Steam achievements bug

#3 Post by dragondatingsim »

Here is an example for granting an achievement:

Code: Select all

 if persistent.c1blood == False:

            $ persistent.c1blood = True
            
            $ achievement.grant("Blood Donation")
            
            $ persistent.achievements += 1
            
            play sound "fx/system.wav"
            
I think the most likely culprit is our in-game achievements screen.

It's supposed to synchronize achievements between our system and Steam, so once displayed, it checks for achievements achieved in our in-game sysstem and grants them on Steam:

Code: Select all

hbox:
                spacing 5
                
                if persistent.c1blood == True:
                    
                    add "achievements/blood_donation.png" xalign 0.5
                    $ achievement.grant("Blood Donation")
However, triggering this screen isn't causing the achievements to appear on Steam, and the number of achievements granted this way is also inconsistent with the screen itself and apparently different every time it happens.

These two are the only instances achievement.grant is used. And why of all things, quitting the game would trigger achievements on Steam is beyond me.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3809
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Steam achievements bug

#4 Post by Imperf3kt »

The problem, as I see it, is that your persistent has no default. It is neither true, nor false.
Upon it being made false, you make it true. Why?
I assume you are checking the achievement has not already been earned?

I suggest changing that so the order is reversed.

Define a default state for achievement earned status at the start of the game.
Check if earned is true. Upon condition met: grant achievement if earned is false, thus, earned becomes true, otherwise does nothing.

To avoid reloading the game, or a new game erasing the true status, add a clause that checks if earned == true before tou define it as default.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
dragondatingsim
Regular
Posts: 115
Joined: Sat Feb 14, 2015 10:22 am
Tumblr: angelswithscalywings
Contact:

Re: Steam achievements bug

#5 Post by dragondatingsim »

Imperf3kt wrote:The problem, as I see it, is that your persistent has no default. It is neither true, nor false.
Upon it being made false, you make it true. Why?
I assume you are checking the achievement has not already been earned?

I suggest changing that so the order is reversed.

Define a default state for achievement earned status at the start of the game.
Check if earned is true. Upon condition met: grant achievement if earned is false, thus, earned becomes true, otherwise does nothing.
They are defined as false by default elsewhere. Keep in mind - our own in-game achievement system (with the persistents) works perfectly fine. It's just that we're getting 10-30 Steam achievement grants just from returning to the main menu from the game for some reason.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3809
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Steam achievements bug

#6 Post by Imperf3kt »

Then it sounds like your default is overwriting the persistent true state. Maybe?

Try adding an if conditional to the default so it only becomes false if it isn't already true.

Maybe

Code: Select all

if not persistent.c1blood:
    $ persistent.c1blood = False
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
PyTom
Ren'Py Creator
Posts: 16097
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Steam achievements bug

#7 Post by PyTom »

Also, you're not allowed to put code with side-effects - like granting an achievement - in a screen. Code in a screen may be run multiple times during image prediction, even if it's in something like an if statement. So that could be what's causing the spurious activations.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
dragondatingsim
Regular
Posts: 115
Joined: Sat Feb 14, 2015 10:22 am
Tumblr: angelswithscalywings
Contact:

Re: Steam achievements bug

#8 Post by dragondatingsim »

PyTom wrote:Also, you're not allowed to put code with side-effects - like granting an achievement - in a screen. Code in a screen may be run multiple times during image prediction, even if it's in something like an if statement. So that could be what's causing the spurious activations.
That would explain it.

We'll try something different, then. Thanks!

Post Reply

Who is online

Users browsing this forum: Ocelot