Achievements & variables

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
Mia
Newbie
Posts: 6
Joined: Sat Jul 08, 2017 6:46 pm
Location: Canada
Contact:

Achievements & variables

#1 Post by Mia »

Hi!
I’m a big newbie when it come to coding and there are ‘’specials’’ type of steam achievements I want to put in my VN. I have no idea how to trigger an achievement for...
1. Playing the game in one language, so one achievement for English and another for French.
2. Using the Skip function.
3. Playing the game on a certain day, like Halloween.
4. Playing the game for x hours, let’s say two.
While lurking around the forums, I found some pieces of codes, but I’m pretty sure they won’t work if I put them like this.

Code: Select all

init:
    $ import time
$ year, month, day, hour, minute, second, dow, doy, dst = time.localtime()
if month == 3 and day == 11:
$achievement.grant("birthday") 
if month == 10 and day == 31:
$achievement.grant("halloween") 
if get_skipping:
$achievement.grant("skip")
if Language = None:
$achievement.grant("french")
if Language = "English":
$achievement.grant("english")
$ hours= (int(renpy.get_game_runtime()) / 3600)
$ minutes= (int(renpy.get_game_runtime()) / 60)
if hours == 2:
$achievement.grant("twohours")
EDIT : I did look at the Ren’py documentations and I tried the code above. I also spend a good two hours looking around the forums, hoping to find a solution. No luck.

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Achievements & variables

#2 Post by Scribbles »

Did you run that code? (with correct indentation?) I'm not sure if renpy can import python stuff or not
Image - Image -Image

Mia
Newbie
Posts: 6
Joined: Sat Jul 08, 2017 6:46 pm
Location: Canada
Contact:

Re: Achievements & variables

#3 Post by Mia »

Yes, I did and I got this with my lint report.


Ren'Py 6.99.12.4.2187 lint report, generated at: Sun Jul 09 12:46:37 2017

game/script.rpy:11 'Language = None' could not be compiled as a python expression, in a condition of the if statement.

game/script.rpy:13 'Language = "English"' could not be compiled as a python expression, in a condition of the if statement.

EDIT: With a small fix, the lint don't give me errors anymore, but I had tested it on Steam and the achievements do not work. I put the code before the label start, where the script goes.

Code: Select all

if Language == None:
    $achievement.grant("french")
if Language == "English":
    $achievement.grant("english")

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Achievements & variables

#4 Post by korova »

"Language" is not a variable but a screen function
see there =>https://www.renpy.org/doc/html/translat ... e#Language

To test the language that is currently used, you could use _preferences.language
see there =>https://www.renpy.org/doc/html/translat ... s.language

As for the achievement system, I can't help, I never used that.

Alem
Regular
Posts: 38
Joined: Wed Mar 15, 2017 7:53 am
Contact:

Re: Achievements & variables

#5 Post by Alem »

Check your Steam first - did you save the achievements AND publish them? I had a similar problem which I caused myself with not publishing updated info in the last "Publish" tab.

If it's not working for you try putting achievement.Sync() into your init python block. Plus try to experiment with the granting process itself like putting $achievement.Sync() after the .grant in your script. Or try to swap $achievement.grant("YOUR NAME") for $achievement.register("YOUR NAME").

In all honesty, I'm a newbie myself and I put all commands in a succession. It's and overkill without a doubt buuuuut it works, so who cares?

Mia
Newbie
Posts: 6
Joined: Sat Jul 08, 2017 6:46 pm
Location: Canada
Contact:

Re: Achievements & variables

#6 Post by Mia »

I’m so sorry for the late reply. In the end, I won’t use those ‘’specials’’ achievements. I already have a lot of them by progressing in the story and they work fine.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Houseofmine