Trouble with Info Screen

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
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Trouble with Info Screen

#1 Post by lovebby »

I was trying to apply the info screen to my game, and it worked fine until I tried adding to it, and I don't know what to do?

Code: Select all

init python:
    # declares a class called 'char'
    default_var = '???'
    class char:
        #--------------------------VV--------if you want to change how much affection they start with
        def __init__(self, affection=0, name=default_var,species=default_var, age=default_var, birthday=default_var, trade=default_var, hobby=default_var, likes=default_var, dislikes=default_var, description=default_var, motto=default_var, dateable=True, pic='none'): #<-- this line sets all the defaults; the only one you'll probably use
            self.affection=affection
            self.name = name
            self.species = species
            self.age = age
            self.birthday = birthday
            self.trade = trade     
            self.hobby = hobby
            self.likes = likes
            self.dislikes = dislikes
            self.description = description
            self.motto = motto
            self.dateable=dateable
            self.pic=pic
            #You can add more areas if you want, just put self. and whatever it is you need
           
        def add_affection(self, amount):
            self.affection += amount
            if self.affection > affectionMax: 
                self.affection = affectionMax
               
        def normalize(self):
            if self.affection > affectionMax: 
                self.affection = affectionMax
            if self.affection < 0:
                self.affection = 0
               
init:
    #declare all the characters here, use the following format. Add as many as you want or need.
    $ Millicent = char(
        name="Milli", 
        species="Nope",
        age="-",
        birthday="-",
        trade="Clothier",
        hobby="-",
        likes="bob",
        dislikes="unknown",
        description="Friendly & bubbly", 
        motto="Giggles.",
        dateable=False,
        pic="c/Milli/millichibi.png"
        )   
    $ Adam = char(
        name="Milli", 
        species="Nope",
        age="-",
        birthday="-",
        trade="Clothier",
        hobby="-",
        likes="bob",
        dislikes="unknown",
        description="Friendly & bubbly", 
        motto="Giggles.",
        dateable=True,
        pic="c/Milli/millichibi.png"
        )   
   
    #these are the characters shown on the screen, you can add more as you meet new people
    $ allchars = [girl, boy]
       
    $ affectionMax = 100 #<-- maximum affection value is changed here
    $ show_profiles = False
    $ viewing = "Girl" #<-- the default character to show when the info screen is first called
       
screen profile_screen:
     tag menu
     zorder 10
     # creates a string for proper display of each fact (+some bars)
     for i in allchars:
            $ char = i
            if viewing == char.name:
               $ name = "Name: " + char.name
               $ species = "Species: " + char.species
               $ trade = "Trade: " + char.trade
               $ age = "Age: " + char.age
               $ birthday = "Date of Birth: " + char.birthday
               $ hobby = "Hobby: " + char.hobby
               $ likes = "Likes: " + char.likes
               $ dislikes = "Dislikes: " + char.dislikes
               $ description = char.description
               $ motto = "Motto: \n \"" + char.motto + "\""
               $ pic = char.pic
               #if char == main: ##For the main character
                   #$ affectionBar = False
                   #$ friendshipBar = False
               if char.dateable: ##If you define the main character, change this statement to elif
                   $ affectionBar = True
                   $ friendshipBar = False   
               else:
                   $ affectionBar = False
                   $ friendshipBar = True
               $ affection = char.affection   
     
     #actually displays everything         
     frame xminimum 240 xmaximum 240 yminimum ymax:
       style_group "infoscreen" 
       vbox yalign 0.5 xalign 0.5:
          for i in allchars:
             #$ textbutton_name, dummy1, dummy2 = i.name.partition(' ') #cuts off the name after the first space
             textbutton i.name action SetVariable("viewing", i.name) xminimum 220 xmaximum 220 yminimum 50   
             #code for future imagebuttons
             #imagebutton idle "i.idlepic" hover "i.hoverpic" action SetVariable("viewing", i.name)
             $ i.normalize()
          textbutton "Return" action Return() ypos 0.8

     window xanchor 0 xpos 240 yalign 0 xminimum 784 xmaximum 784 yminimum ymax ymaximum ymax:
      style_group "infoscreen"   
      vbox spacing 10:
          vbox:
               text name
               text species
               if trade != 'Trad: ???':
                  text trade
               text age
               text birthday
               text hobby
          vbox xmaximum 500:     
               text likes
               text dislikes
          vbox spacing 10 xmaximum 490: 
              text description
              text motto           
              hbox ypos 0.7:
                if affectionBar:         
                       text "Love:" 
                       bar value affection range affectionMax style "infoscreen_bar" right_bar "bar_empty-pink.png" left_bar "bar_full-pink.png"
                if friendshipBar:
                       text "Relationship:" 
                       bar value affection range affectionMax style "infoscreen_bar"
      if pic != 'none':
               add pic xalign 0.6 yalign 0.0 #Tinker with these numbers as needed to change where the image goes
I'm sorry, but an uncaught exception occurred.

While running game code:
File "renpy/common/_layout/screen_main_menu.rpym", line 11, in script
File "game/CharProfiles.rpy", line 79, in python
AttributeError: char instance has no attribute 'species'

Code: Select all

$ species = "Species: " + char.species
is line 79

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Trouble with Info Screen

#2 Post by Alex »

You have

Code: Select all

init:
    #declare all the characters here, use the following format. Add as many as you want or need.
    $ Millicent = char(
 ... ... ...

    $ Adam = char(
 ... ... ...

    #these are the characters shown on the screen, you can add more as you meet new people
    $ allchars = [girl, boy]
The allchars list should have only the characters you've declared

Code: Select all

    $ allchars = [Millicent, Adam]  # case sensitive
Also, check the Adam's name.

User avatar
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Re: Trouble with Info Screen

#3 Post by lovebby »

Ah yes, I added that in afterwards I say that aha.
It still doesn't change anything about the species thing though?

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Trouble with Info Screen

#4 Post by Elmiwisa »

Try moving that line down to see if a different error occur. In fact, rearrange the lines from the "species" line to the "pic" line and see what other error you have.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Trouble with Info Screen

#5 Post by Alex »

That's strange - I've tried your code and it worked (wherever I put the button to call info screen - main menu or quick menu).
Check if you still have definitions for default boy and girl somewhere in your script files that does not have attribute 'species' (you should comment this code out or move the file outside of the game folder).

Also,

Code: Select all

$ viewing = "Girl" #<-- the default character to show when the info screen is first called
should be

Code: Select all

$ viewing = "Milli" #<-- the default character to show when the info screen is first called

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Trouble with Info Screen

#6 Post by Elmiwisa »

Alex wrote:That's strange - I've tried your code and it worked (wherever I put the button to call info screen - main menu or quick menu).
Check if you still have definitions for default boy and girl somewhere in your script files that does not have attribute 'species' (you should comment this code out or move the file outside of the game folder).

Also,

Code: Select all

$ viewing = "Girl" #<-- the default character to show when the info screen is first called
should be

Code: Select all

$ viewing = "Milli" #<-- the default character to show when the info screen is first called
Even if the attribute are not set, it will still get the default value, as long as it is still created using that __init__ method. And if it is not created that way, then why does it have the name attribute? (if it doesn't, the error would come from the "name" line). It seems like the attribute have to be deleted for this error to occur. And beside, lovebby removed the "girl" and "boy" from the list per your suggest already isn't it?
Or perhaps there is some sort of bug here and Ren'Py do not realize that the game script is updated and still use the old version.

User avatar
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

Re: Trouble with Info Screen

#7 Post by Ayutac »

Elmiwisa wrote:Or perhaps there is some sort of bug here and Ren'Py do not realize that the game script is updated and still use the old version.
I have a diffuse feeling I had this behaviour once before. I suggest deleting the .rpyc file (have you changed the file name?) and maybe a restart.

You could try another class name too.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

Post Reply

Who is online

Users browsing this forum: No registered users