Extended Achievements invalid Syntax Error

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
Suru
Regular
Posts: 111
Joined: Wed Aug 31, 2016 10:27 pm
Contact:

Extended Achievements invalid Syntax Error

#1 Post by Suru » Tue Aug 27, 2019 10:21 am

Hello. I'm working with the extended achievement code and it'll work fine for the first extended achievement...however, I continue to get an error if I use more than one extended achievement.

Code: Select all

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 achievements here
    if not persistent.achievements_dict:
        persistent.achievements_dict = {  #(All the one time achievements were here but I took them out to save space)
                                                                        
                                        "Damsel": {"type": 1, # Progress achievement One
                                                             "title": "Damsel",
                                                             "text": "Got every possible rescue in week one.",
                                                             "icon": "achieve2small.jpg",
                                                             "cur_prog": 0, # current progress 
                                                             "max_prog": 9# maximal progress
                                                             }
                                        "EmoKid": {"type": 1, # Progress achievement Two
                                                             "title": "Emo Kid",
                                                             "text": "All the Bad Ends",
                                                             "icon": "achieve2small.jpg",
                                                             "cur_prog": 0, # current progress 
                                                             "max_prog": 11# 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'])
The rest of the code used for the achievements works fine (including the 'Damsel' extended achievement) but when it reaches the second achievement on this list "Emokid" I get this error:

invalid syntax (for the line of code that begins the second extended achievement) "EmoKid" ->: {"type": 1,

I am pretty sure all the lines are the same other than the variables in names. So I'm confused as to how the syntax is invalid. I'd appreciate any help.

rayminator
Miko-Class Veteran
Posts: 754
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Extended Achievements invalid Syntax Error

#2 Post by rayminator » Wed Aug 28, 2019 8:21 am

here try this it's telling something is not line up properly i am not 100% sure i use atom i have the indentation line on it showed it was not line up

Code: Select all

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 achievements here
    if not persistent.achievements_dict:
        persistent.achievements_dict = {  #(All the one time achievements were here but I took them out to save space)
                                                                        
                                        "Damsel": {"type": 1, # Progress achievement One
                                                            "title": "Damsel",
                                                            "text": "Got every possible rescue in week one.",
                                                            "icon": "achieve2small.jpg",
                                                            "cur_prog": 0, # current progress 
                                                            "max_prog": 9# maximal progress
                                                            }
                                        "EmoKid": {"type": 1, # Progress achievement Two
                                                            "title": "Emo Kid",
                                                            "text": "All the Bad Ends",
                                                            "icon": "achieve2small.jpg",
                                                            "cur_prog": 0, # current progress 
                                                            "max_prog": 11# 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'])

Post Reply

Who is online

Users browsing this forum: Google [Bot]