Extended achievements

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
OlegWock
Newbie
Posts: 2
Joined: Mon Aug 15, 2016 10:01 am
Github: https://github.com/OlegWock
Contact:

Extended achievements

#1 Post by OlegWock »

Hello. I recently translated docs for my achievements module into english. Translation is very ugly, but I hope it's usable.

Roselia-achievements

This is small module for RenPy, thats implent custom achievements. It's devloping as part of Project Roselia, that [will] contain other small scripts with different features for RenPy.

It has:
  • One-time achievements
  • Achievements with progress
  • Steam compatibility (in future)
  • Ability to change achievements screen and animation
  • Simple architecture that allows you to add new features
  • Works over standart achievement
Full docs: https://github.com/OlegWock/Roselia-achievements

Screenshot:
Image

User avatar
Lin Augustine
Newbie
Posts: 7
Joined: Fri Aug 12, 2016 7:05 pm
Completed: Who Stole the Snow Globe?
Projects: Who Stole the Snow Globe?, The First Sunset
Tumblr: linaugustineart
Location: Florida, U.S.
Contact:

Re: Extended achievements

#2 Post by Lin Augustine »

This is very handy, but it wasn't working for me at first (I kept getting errors).

I changed this:

Code: Select all

if not persistent.achievements_dict:
        persistent.achievements_dict = {"test1": {"type": 0, # One time achievement
                                                             "title": "Yay!", # Also name for steam
                                                             "text": "Wow you've achieved!", # description
                                                             "icon": "images/icons/ach.png" # 96x96 image
                                                             },
                                        "test2": {"type": 1, # Progress achievement
                                                             "title": "Progress!",
                                                             "text": "Making progress...",
                                                             "icon": "images/icons/ach2.png",
                                                             "cur_prog": 0, # current progress 
                                                             "max_prog": 3# maximal progress
                                                             }
                                        }
                                        

        for i, a in persistent.achievements_dict.items():
            if a['type'] == 0:
                achievement.register(i, steam=a['title'])
            if a['type'] == 1:
                achievement.register(i, steam=a['title'], stat_max=a['max_prog'])
To this:
(I just removed the line "if not persistent.achievements_dict:" and fixed the indentation).

Code: Select all

persistent.achievements_dict = {"test1": {"type": 0, # One time achievement
                                                             "title": "Yay!", # Also name for steam
                                                             "text": "Wow you've achieved!", # description
                                                             "icon": "images/ach.png" # 96x96 image
                                                             },
                                          "test2": {"type": 1, # Progress achievement
                                                             "title": "Progress!",
                                                             "text": "Making progress...",
                                                             "icon": "images/ach2.png",
                                                             "cur_prog": 0, # current progress 
                                                             "max_prog": 3# maximal progress
                                                             }
                                        }
                                        

    for i, a in persistent.achievements_dict.items():
        if a['type'] == 0:
            achievement.register(i, steam=a['title'])
        if a['type'] == 1:
            achievement.register(i, steam=a['title'], stat_max=a['max_prog'])
And I don't know why but it works for me now.

OlegWock
Newbie
Posts: 2
Joined: Mon Aug 15, 2016 10:01 am
Github: https://github.com/OlegWock
Contact:

Re: Extended achievements

#3 Post by OlegWock »

Lin Augustine wrote:This is very handy, but it wasn't working for me at first (I kept getting errors).

I changed this:


To this:
(I just removed the line "if not persistent.achievements_dict:" and fixed the indentation).


And I don't know why but it works for me now.

Can you show that error?

User avatar
Lin Augustine
Newbie
Posts: 7
Joined: Fri Aug 12, 2016 7:05 pm
Completed: Who Stole the Snow Globe?
Projects: Who Stole the Snow Globe?, The First Sunset
Tumblr: linaugustineart
Location: Florida, U.S.
Contact:

Re: Extended achievements

#4 Post by Lin Augustine »

Hmm, it's been a while since I played around with this. I tried to duplicate the error that I was getting in the past (it was something like "achievements_dict is not defined"), but it works fine for me now in the tester game that I used. I'm not sure what I did before, but the code works perfectly now. Sorry about that!

theravano
Newbie
Posts: 6
Joined: Wed Aug 02, 2017 3:10 pm
Organization: Bearcade Games
itch: bearcade
Contact:

Re: Extended achievements

#5 Post by theravano »

Sorry but, how do i call for the achievements on the Script?

User avatar
Jukado
Newbie
Posts: 9
Joined: Fri Nov 03, 2017 6:33 am
Projects: Working on Visual Novel
IRC Nick: Juju
Location: France
Contact:

Re: Extended achievements

#6 Post by Jukado »

I test this modul and it is very great !
by theravano » Mon Aug 07, 2017 4:47 pm
Sorry but, how do i call for the achievements on the Script?

I will try to contribute to answer to theravano :D
To implement the code and "call" the achievement in your currently game, you have to :
Put the achievement.rpy file before the label start and add a code lign.
Here is my code :

Code: Select all

# Déclarez les personnages utilisés dans le jeu.
define e = Character('Eileen', color="#c8ffc8")

##### Achievement

################################################ Before label start 

transform achievement_transform:
    on show:
        xalign .98 
        yalign -.3 
        linear 0.4 xalign .98 yalign .02
    on hide:
        linear 0.4 xalign 1.9 yalign .02

screen scr_achievement_get(title, a_text, icon, trans=achievement_transform):
    timer 2.4 action Hide("scr_achievement_get")
    window:
        at trans
        background "#333333cc"
        xalign .98
        yalign .02
        xysize (450, 100)
        hbox:
            vbox:
                spacing 10
                image icon
            vbox:
                xoffset 10
                xsize 330
                text title:
                    size 28
                    id title
                text a_text:
                    size 22
                    id a_text

screen scr_achievement_update(title, a_text, icon, cur_prog, max_prog, trans=achievement_transform):
    timer 2.4 action Hide("scr_achievement_update")
    window:
        at trans
        background "#333333cc"
        xalign .98
        yalign .02
        xysize (450, 100)

        #

        hbox:
            vbox:
                spacing 10
                image icon
                text "{0}/{1}".format(cur_prog, max_prog):
                    xcenter 0.5 
                    ycenter 0.2
            vbox:
                xoffset 10
                xsize 330
                text title:
                    size 28
                    id title
                text a_text:
                    size 22
                    id a_text


                



init python:
    def get_achievement(ach_id, trans=achievement_transform):
        ach = persistent.achievements_dict[ach_id]
        achievement.grant(ach_id)
        renpy.show_screen(_screen_name='scr_achievement_get', title=ach['title'],
                          a_text=ach['text'], icon=ach['icon'], trans=trans)

    def update_achievement(ach_id, to_add=1, trans=achievement_transform):
        persistent.achievements_dict[ach_id]["cur_prog"] += to_add
        ach = persistent.achievements_dict[ach_id]

        achievement.progress(ach_id, to_add)
        if ach['cur_prog'] > ach['max_prog']:
            persistent.achievements_dict[ach_id]["cur_prog"] = ach['max_prog']
            ach = persistent.achievements_dict[ach_id]

        renpy.show_screen(_screen_name='scr_achievement_update', title=ach['title'], a_text=ach['text'],
                          icon=ach['icon'], cur_prog=ach['cur_prog'], max_prog=ach['max_prog'], trans=trans)





    # Define your achievements here
    if not persistent.achievements_dict:
        persistent.achievements_dict = {"name": {"type": 0, # One time achievent
                                                             "title": "Un coeur tendre", # Also neame for steam
                                                             "text": "Relation romantique avec Azur débloquée !", # description
                                                             "icon": "images/Logo Achievement/Coeur.png" # 96x96 image
                                                             },
                                        "name2": {"type": 1, # Progress achievent
                                                             "title": "Le mystère du Chateau",
                                                             "text": "Qui es-ce qui est à l'origine de ça ??",
                                                             "icon": "images/Logo Achievement/Coeur.png",
                                                             "cur_prog": 0, # current progress 
                                                             "max_prog": 33 # maximal progress
                                                             }
                                        }
                                        

        for i, a in persistent.achievements_dict.items():
            if a['type'] == 0:
                achievement.register(i, steam=a['title'])
            if a['type'] == 1:
                achievement.register(i, steam=a['title'], stat_max=a['max_prog'])

##########################################################################################################################

label start:

    #The game starts here

"A test to find how put fade"
    
menu:
    "Lâchez-la !":
        jump oh_Yes
    "Ne rien faire.":
        jump oh_No
        
label oh_Yes:
    
e "Bla bla"
    
$ get_achievement("name", trans=achievement_transform)  ######## in the script, there wasn't " ", i add it.

e "A problem ?"

label oh_No:
    
e "no way !!!!"

return  
i hope it will help you and i hope that don't make mistakes in my explanation :)

User avatar
Omega Fallon
Newbie
Posts: 6
Joined: Thu Feb 22, 2018 11:46 am
Projects: Scarlet-sama's Family
Organization: Team Abnormality Adventures
Tumblr: omegafallon
Soundcloud: omega-fallon
itch: omegafallon
Contact:

Re: Extended achievements

#7 Post by Omega Fallon »

How would I make it so that it dissolves/fades in and out instead of sliding off screen?
Make something cool and unique that you be proud of and then share it with everyone.

Post Reply

Who is online

Users browsing this forum: No registered users