Simple indexation 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
sculpteur
Veteran
Posts: 221
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Simple indexation error

#1 Post by sculpteur » Sat Apr 09, 2022 10:57 pm

Hey guys !

So I was going to finally try to implement an achievment system to my game that I found here : https://github.com/OlegWock/Roselia-ach ... vement.rpy (it is not a robbery since this is free open source ^^ )

BUT

I didn't even begin to work on the adaptation to my existing code than I'am getting this syntax error.
I was thinking it may come from an indexation mistake (with the tabulation space for exemple) but everything I tried seem to make it worst lol

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.

File "game/screen_3_complexescreen.rpy", line 201: invalid syntax
                                                                     "cur_prog": , 
                                                                                  ^
    
Ren'Py Version: Ren'Py 7.4.11.2266
Sun Apr 10 04:35:25 2022
So if anyone have an idea from where this is coming from let me know please :mrgreen:

Ohw and, also, If someone know a better (easier) free achievement system that I could use don't hesitate to tell me.
I'm not sayin' this because the author seems to be russian or something but because it comming from 17 Sep 2017 when I stared coding in Renpy, at the time I found this an put the link on my desk and this morning I opened it and say "hey, right ! It was the achievement system I was planning to implement" :lol:
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Simple indexation error

#2 Post by Ocelot » Sun Apr 10, 2022 2:46 am

On line 201 of screen_3_complexescreen.rpy you forgot to put a value between "cur_prog" dictionary key and comma.
< < insert Rick Cook quote here > >

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

Re: Simple indexation error

#3 Post by rayminator » Sun Apr 10, 2022 6:39 am

this is the part that's giving you the error

Code: Select all

# Define your achievements here
    if not persistent.achievements_dict:
        persistent.achievements_dict = {"*achievent_name*": {"type": 0, # One time achievent
                                                             "title": "Котик!", # Also neame for steam
                                                             "text": "А где же блины?", # description
                                                             "icon": "images/icons/ach1.png" # 96x96 image
                                                             },
                                        "*achievent_name*": {"type": 1, # Progress achievent
                                                             "title": "",
                                                             "text": "",
                                                             "icon": "images/icons/ach.png",
                                                             "cur_prog": , # current progress <--- this one it's either a 0 or "" or "name" but mostly like a 0
                                                             "max_prog": # maximal progress <--- this one as well
                                                             }
                                        }

User avatar
sculpteur
Veteran
Posts: 221
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Simple indexation error

#4 Post by sculpteur » Sun Apr 10, 2022 12:17 pm

Yep exactly thank you and I fixed it but there is something I don't understand it's why now renpy told me that my variables are not define.

When the code arrived to this line : $ get_achievement(test, trans=achievement_transform)
I got this error :

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/scene_StoryProg1_A_Darkbasment.rpy", line 924, in script
    $ get_achievement(test, trans=achievement_transform)
  File "game/scene_StoryProg1_A_Darkbasment.rpy", line 924, in <module>
    $ get_achievement(test, trans=achievement_transform)
NameError: name 'test' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/scene_StoryProg1_A_Darkbasment.rpy", line 924, in script
    $ get_achievement(test, trans=achievement_transform)
  File "renpy/ast.py", line 928, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "renpy/python.py", line 2245, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/scene_StoryProg1_A_Darkbasment.rpy", line 924, in <module>
    $ get_achievement(test, trans=achievement_transform)
NameError: name 'test' is not defined

Windows-8.1-6.3.9600
Ren'Py 7.4.11.2266
Apocalypse' lovers 0.1
Sun Apr 10 18:16:11 2022

I've try a lot of different combinaison in this (the comment line are what I try in first, then I removed the IF condition to see if it was comming from there but nothing seems to work.

Code: Select all

# Define your achievements here
    persistent.achievements_dict = {"test": {"type": 0,
                                             "title": "zz",
                                             "text": "qsdqsd",
                                             "icon": "images/icons/ach.png"
                                            },
                                    "nome": {"type": 1,
                                             "title": "",
                                             "text": "",
                                             "icon": "images/icons/ach.png",
                                             "cur_prog": 0,
                                             "max_prog": 33
                                            }
                                    }
    # if not persistent.achievements_dict:
    #     persistent.achievements_dict = {"test": {"type": 0, # One time achievent
    #                                                         "title": "Котик!", # Also neame for steam
    #                                                         "text": "А где же блины?", # description
    #                                                         "icon": "images/icons/ach1.png" # 96x96 image
    #                                                         },
    #                                     # "achievent_name2": {"type": 0, # One time achievent
    #                                     #                      "title": "Zizi!", # Also name for steam
    #                                     #                      "text": "Mange mon zizi", # description
    #                                     #                      "icon": "images/icons/ach1.png" # 96x96 image
    #                                     #                      },
    #
    #
    #                                     "*achievent_name*": {"type": 1, # Progress achievent
    #                                                          "title": "",
    #                                                          "text": "",
    #                                                          "icon": "images/icons/ach.png",
    #                                                          "cur_prog": "", # current progress
    #                                                          "max_prog": "" # maximal progress
    #                                                          }
    #                                     }

I also try to change init python: by init -1 python but this it's not working neither.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

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

Re: Simple indexation error

#5 Post by rayminator » Sun Apr 10, 2022 12:23 pm

you have to define test that's all

what is test for?

define or default test = "" or [] or {} or 0

User avatar
sculpteur
Veteran
Posts: 221
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Simple indexation error

#6 Post by sculpteur » Sun Apr 10, 2022 12:53 pm

Isn't "test" define by those line :

Code: Select all

    persistent.achievements_dict = {"test": {"type": 0,
                                             "title": "zz",
                                             "text": "qsdqsd",
                                             "icon": "images/icons/ach.png"
or those lines (in my previous try) :

Code: Select all

     if not persistent.achievements_dict:
         persistent.achievements_dict = {"test": {"type": 0, # One time achievent
                                                             "title": "Котик!", # Also neame for steam
                                                             "text": "А где же блины?", # description
                                                             "icon": "images/icons/ach1.png" # 96x96 image
                                                             },
It is supposed to be the name of an achievement that includes different characteristics (value, such as title, images, etc).
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

jeffster
Regular
Posts: 123
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Simple indexation error

#7 Post by jeffster » Sun Apr 10, 2022 1:01 pm

Nope. You define

Code: Select all

persistent.achievements_dict["test"]

# So you can do:

a = persistent.achievements_dict["test"]
But it's not the same as

Code: Select all

test

# So you can not do:

a = test

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

Re: Simple indexation error

#8 Post by rayminator » Sun Apr 10, 2022 1:59 pm

sculpteur wrote:
Sun Apr 10, 2022 12:53 pm
Isn't "test" define by those line :

Code: Select all

    persistent.achievements_dict = {"test": {"type": 0,
                                             "title": "zz",
                                             "text": "qsdqsd",
                                             "icon": "images/icons/ach.png"
or those lines (in my previous try) :

Code: Select all

     if not persistent.achievements_dict:
         persistent.achievements_dict = {"test": {"type": 0, # One time achievent
                                                             "title": "Котик!", # Also neame for steam
                                                             "text": "А где же блины?", # description
                                                             "icon": "images/icons/ach1.png" # 96x96 image
                                                             },
It is supposed to be the name of an achievement that includes different characteristics (value, such as title, images, etc).

depend on how you are using test for is it in a class or by itself?

User avatar
sculpteur
Veteran
Posts: 221
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Simple indexation error

#9 Post by sculpteur » Sat Apr 16, 2022 3:50 pm

what is test for?
As to the author of this system explain here : (https://github.com/OlegWock/Roselia-achievements)

I think it's supposed to be used this way :

Code: Select all


$ get_achievement(name, trans=achievement_transform) # to award a one-time achievement

So when you write this :
define or default test = "" or [] or {} or 0
I suppose it will define a different kind of variable according to the sign after the equal

So what do you think I should choose in order to be able to define those achievement?
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

Post Reply

Who is online

Users browsing this forum: enaielei