Page 1 of 1

Achievements & variables

Posted: Sat Jul 08, 2017 6:57 pm
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.

Re: Achievements & variables

Posted: Sun Jul 09, 2017 9:10 am
by Scribbles
Did you run that code? (with correct indentation?) I'm not sure if renpy can import python stuff or not

Re: Achievements & variables

Posted: Sun Jul 09, 2017 12:47 pm
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")

Re: Achievements & variables

Posted: Mon Jul 10, 2017 5:58 am
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.

Re: Achievements & variables

Posted: Tue Jul 11, 2017 1:14 pm
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?

Re: Achievements & variables

Posted: Thu Jul 13, 2017 7:11 pm
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.