Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Achievements for Ren'Py

In-depth ingame achievement support for Ren'Py that plugs into the Steam backend. · By Feniks

Need Support? Post here! Sticky

A topic by Feniks created Sep 14, 2023 Views: 643 Replies: 42
Viewing posts 1 to 16
Developer

If you're having trouble or run into any bugs with the code, post a comment here! I will try to get back to you within a few days.

Hey, bro. How do you set up a steam connection? 

Developer(+2)

Hello! In Steamworks, you can go to Technical Tools > Edit Steamworks Settings > Stats & Achievements > Achievements and add a new achievement. The first column, called API Name, is the ID for the achievement. This should be the same ID as you set when you make your Achievement objects in-game using the system. You can then add the locked/unlocked images in Steamworks as per usual. The only important thing is that the achievement has the same ID as the in-game one! Aside from that, the backend of registering and granting the achievement for Steam is all taken care of via the system. Hope that helps!

Thanks for the quick response! I added an achievement with the same ID as in your Example 1 to Steamworks. I also added a steam_appid.txt file with the game id near the .exe file. The in-game achievement works (using $ sample_achievement.grant() ), but it is not granted at Steam. I run the game through Steam and the overlay (Shift+tab) works.

 

Developer(+1)

Did you install the Steam support from the Ren'Py launcher? That's required for any Steam integration. Remember also that you'll have to go through Steam to clear any achievements if you'd like to re-see the popup, as the clear method only clears it on Ren'Py's end. You can install the Steam support via the launcher Preferences -> Install Libraries -> Install Steam Support. The overlay isn't related to whether Steam support is installed or not, just if you're playing it through Steam. Let me know if that fixes it for you!

It's all working now! Thank you!

Hey, this is probably a stupid question, but in what script do you need to write the first code?

Developer

If I understood your question - you can declare the achievements in whichever rpy file in your project you like. The included achievements.rpy file has several example achievements, so it probably makes sense to declare your own achievements there. Be sure to read the included README for more instructions on what details you can provide to each achievement as well! You might consider reading https://feniksdev.com/organizing-a-renpy-project/ if you're new to Ren'Py project organization in general.

Deleted 287 days ago
Developer

Sure thing! You can remove the achievement gallery screen or just not use it anywhere. The popups will work just fine. 

Same thing goes in reverse, too - you can use the config options at the top of the file to remove popups and just use the gallery if you like.  

Deleted 287 days ago
Developer

So if I understood, you just want a notification screen? You certainly don't need to go through the achievement system for that; just make yourself a screen and show it with your desired notification. You can copy the general format of the achievement popup screen and methods for that, but I'm afraid that would be out of the scope of things I can help with for this system.

(1 edit)

Hi, I was having difficulties accessing the achievement screen on my main menu so I looked around and found that deleting the second datetime (line 131 and 148) in the achievements backend solved it. I do not know if it's a bug on my end or my game but thought I'd let you know! Fanatastic asset, very excited to customise it!

Developer

The current achievement code is correct! But sometimes other people import the datetime module separately, which could cause this conflict. It usually looks like from datetime import datetime instead of just import datetime. I would check your project for other places where the datetime module is used to see what's causing that. If you've imported datetime differently, then your fix will work.

Glad you like the system! I hope you find it useful :)

Hello! Thank you very much for the great feature!

As I was testing out the achievement pop-ups I saw that the name of the achievements and descriptions were not showing up, then I realized I set gui.text_color in gui.rpy to black, is there a way to make the achievement text not rely on the same gui type as that of dialogue? Or is there a way to change the color of the popup box to white?

I sincerely apologize for any inconvenience :c

Developer(+1)

Sure! You can change the text colour of any of the screens however you like by adjusting the styles; all of the existing styling is meant to be changed to suit your project. I suggest you hover over the text in question and hit shift+i to find which styles are affecting it, or you can find the lines in achievements.rpy and just add color "#fff" or similar to whichever line of text you need. For example, you can change the line text a.description size 25 to text a.description size 25 color "#fff" to make the text white. Hope that helps!

I figured it out! Thank you very much!

Because of the code in the first image for a minigame, the code in the second image stops working 

https://imgur.com/a/udq9pEE

Developer

Yes, time is a reserved name that refers to the Python library time. Call the variable something else and it should work.

the problem is that the minigame uses that time variable to countdown to the end of each phase. im not entirely sure what to change in order to separate the countdown time from the default time https://imgur.com/ZxmZGCv

Developer

Find and replace the variable time with some other name - it can be whatever you like. It's just a variable name, and it'll be better to change it to avoid conflicts with Python libraries.

did so, but this still came up https://imgur.com/Q3G6a2k

nvm there's something i forgot to rewrite! it all works

(1 edit)

i'm sorry, but where do i need to put this?..

textbutton _("Achievements") action ShowMenu("achievement_gallery")
Developer

It's not a requirement or anything! That's just an example of a button you can make so players can see your achievement gallery. In a standard Ren'Py project, that would go on screen navigation in the same pattern as all the other buttons there. But you can create whatever kind of button or method to access the achievement gallery that you want.

Oh, okay... I would like a video tutorial, since i'm not good at English at all... Do you have it, or you know if someone did it already?

Developer

You can look up regular screen language in Ren'Py for more information on how UI works in Ren'Py. I have some tutorials on my website also https://feniksdev.com/navigation/

(1 edit)

Hello, my friend. Just one stupid question.

In achievement_backend.rpy, line 457:

ACHIEVEMENT_SOUND = "audio/interface/ach.ogg"

I got the right path and there's no problem with this sound, but in-game granting going without any sound. I really don't know, why, mb I need to change smth, not the only one line?

Sound channel is also correct

btw sry my english is bad and im drunk a little
Developer

You're meant to change the sound with your own define statement, not in the backend file! For example,

define myconfig.ACHIEVEMENT_SOUND = "audio/interface/ach.ogg"

The achievements.rpy file has examples of that. If you're only changing it in the backend, then the redeclaration in achievements.rpy will be overwriting it with None. The backend file has an early initialization order so it can be set up early before it's used and modified with a regular define statement.

So, in short, change it in achievements.rpy not in the backend file :) Hope that helps!

My gosh it helps I feel so stupid rn. Thanks, brother

Deleted 125 days ago
Deleted 125 days ago

Hey! Just a small question, how do I stop the achievements being opened by clicking on them in the achievements gallery? 

Developer

Hello! That option is only available to developers during development for testing, so if you make a build then players can't toggle achievements. To remove it altogether you can look for the action under a `if config.developer:` block and get rid of it.

Thanks! 

I can't find the Achievements Gallery button in the main menu, I don't know what to do. I tried deleting the datetime in the backend to try and fix it (because I was reading through the other comments here) but that didn't work either. 

Developer

Hello! You have to make a button to lead to the achievement gallery yourself - it's not built into your project or the tool because I don't know how your main menu screen is set up. That's what this bit of code in the instructions is for:

textbutton _("Achievements") action ShowMenu("achievement_gallery")  

You need to add that or something similar to your project to access the achievement gallery. Don't delete datetime either - that was a very specific case where another bit of code had imported datetime already in a different way. I suggest not changing anything in the backend unless you understand what you're doing.

Ok! Thank you

I'm having trouble with coding the Platinum Achievement. I've tried to code different things onto the script file but nothing works and I'm not very experienced in coding. (apart from coding visual novel stuff). What do I do?

Developer

Can you share any code you've tried?

So my game has 15 achievements (14 dis-including Platinum Achievement) sorry if this is a lot

This is what I've coded every time an achievement is unlocked

These are my "if"s I've set up

(The 8th achievement is the bar one, I've already done coding for that one)

And this is the Platinum Achievement code on the achievement script


Developer

So what I'm understanding based on the code you've posted is that you're very new to coding. That's all right, but you will need to have a basic grasp of how variables (getting and setting them) work in order to understand how to use the achievement code. I really recommend you begin with https://feniksdev.com/a-quick-primer-on-variables-in-renpy/ and go through the rest of the tutorials in that series to see how to declare variables and update them. Then I recommend you read over the examples included with the achievements - you should follow the example very closely and just tweak things until they work how you want. A better understanding of variables will help you see what the system is doing and how you can follow the examples to do what you want. Good luck!

This is very useful! Thank you very much

Hi, I am pretty new to Ren'py and coding but I am slowly figuring things out. Here's my issue, I want to make an achivement for skipping the dialogue but I cannot figure out how to make it work. I'd appreciate any help/tips ^^'

Developer(+1)

If you want to check if the player is skipping a specific section of dialogue, you can check for if renpy.is_skipping(): (https://www.renpy.org/doc/html/other.html#renpy.is_skipping) at the start of that dialogue, and if it's true, grant your achievement. Otherwise, you can also add an achievement action to the Skip button on the quick menu (e.g. action [skip_achievement.Grant(), Skip()] on the quick menu button). The latter suggestion will *not* cover the case if the player uses a keyboard key like CTRL or Tab to start skipping; the best way to handle that more general case would be through a callback https://www.renpy.org/doc/html/config.html#var-config.interact_callbacks. If you're new to coding, I would wait to implement the last option until you're a bit more comfortable with Python! I hope that helps :)

Thank you! For now I'll use the second option but once I figure more stuff out I'll check out the callback stuff ^^

Hello! I'm sorry if it sounds like a silly question, but is it possible to change the frame image depending on the achievement?