Some things disappear when loading a saved game >.<

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
Meiting_98
Regular
Posts: 35
Joined: Fri Jul 12, 2013 1:25 pm
Projects: Neutralizing You
Organization: Ninja Vault
Location: Indonesia
Contact:

Some things disappear when loading a saved game >.<

#1 Post by Meiting_98 »

Hello everyone,
I used the infoscreen feature for my game. It works nicely until I found out that if I load a saved game, the character infos will disappear. If I just play from the beginning through the end this won't happen. Can someone tell me how to fix this?

Thank you before

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

Re: Some things disappear when loading a saved game >.<

#2 Post by Alex »

This means that you've changed the character's information the way that can't be properly stored. This should help you to find the cause of the issue - http://www.renpy.org/doc/html/save_load_rollback.html

Meiting_98
Regular
Posts: 35
Joined: Fri Jul 12, 2013 1:25 pm
Projects: Neutralizing You
Organization: Ninja Vault
Location: Indonesia
Contact:

Re: Some things disappear when loading a saved game >.<

#3 Post by Meiting_98 »

This is the info I have

Code: Select all

init python:
    default_var = '???'
    class char:
        def __init__(self, affection=50,  name=default_var, cname=default_var, age=default_var, family=default_var, Element=default_var, dateable=True, pic='none', HP=default_var, SP=default_var): #<-- this line sets all the defaults; the only one you'll probably use
            self.affection=affection
            self.name = name
            self.cname = cname
            self.age = age            
            self.family = family
            self.SP = SP
            self.Element = Element
            self.dateable=dateable
            self.pic=pic
            
            self.HP = HP
            self.SP = SP
       
        def add_affection(self, amount):
            self.affection += amount
            if self.affection > affectionMax:
                self.affection = affectionMax
       
        def add_HP(self, amount):
            self.HP += amount
            if self.HP > HPmax:
                self.HP = HPmax
                
        def add_SP(self, amount):
            self.SP += amount
            if self.SP > SPmax:
                self.SP = SPmax
                
        def normalizeHP(self):
            if self.HP > HPmax:
                self.HP = HPmax
            if self.HP < 0:
                self.HP = 0
        
        def normalizeSP(self):
            if self.SP > SPmax:
                self.SP = SPmax
            if self.SP < 0:
                self.SP = 0
                
        def normalizeAffection(self):
            if self.affection > affectionMax:
                self.affection = affectionMax
            if self.affection < 0: 
                self.affection = 0
                
init:
    $ un = char(
        name="[uname!t]",
        cname="Zhou Qin Ying",
        age="22",        
        family="Ethan",
        Element="Water",
        dateable=False,
        pic="prota.png"
        )
    $ ethan = char(
        name="???", 
        cname="-",
        age="-",        
        family="-",
        Element="-", 
        dateable=False,
        pic="none.png"
        )   
    $ keith = char(
        name="???",
        cname="-",
        age="-",
        family="-",
        Element="-", 
        dateable=False,
        pic="none.png"
        )   
    $ wendy = char(
        name="???",
        cname="-", 
        age="-",        
        family="-",
        Element="-", 
        dateable=False,
        pic="none.png"
        )   
    $ su_lian = char(
        name="???", 
        cname="-", 
        age="-", 
        family="-",
        Element="-",
        dateable=False,
        pic="none.png"
        )   
    $ kyle = char(
        name="???", 
        cname="-", 
        age="-",   
        family="-", 
        Element="-", 
        dateable=False,
        pic="none.png"
        )   
    $ sam = char(
        name="???",
        cname="-",
        age="-",
        family="-",
        Element="-",
        dateable=False,
        pic="none.png"
        )
    $ sea_dragon = char(
        name="???",
        cname="-",
        age="-",   
        family="-",
        Element="-",
        dateable=False,
        pic="none.png"
        )
    $ sky_dragon = char(
        name="???",
        cname="-", 
        age="-",  
        family="-",
        Element="-",
        dateable=False,
        pic="none.png"
        )
    $ titan_crab = char(
        name="???",
        cname="-",
        age="-",  
        family="-",
        Element="-", 
        dateable=False,
        pic="none.png"
        )
    $ old_man = char(
        name="???",
        cname="???", 
        age="???",
        family="???", 
        Element="???",
        dateable=False,
        pic="none.png"
        )
    $ fu_tou = char(
        name="???",
        cname="???",
        age="???",
        family="???",
        Element="???",
        dateable=False,
        pic="none.png"
        )
    $ yu_zheng = char(
        name="???",
        cname="???",
        age="???",
        family="???",
        Element="???",
        dateable=False,
        pic="none.png"
        )
    $ zheria = char(
        name="???",
        cname="-",
        age="???",
        family="???",
        Element="???",
        dateable=False,
        pic="none.png"
        )

    $ allchars = [un, ethan, keith, wendy, su_lian, kyle, sam, sea_dragon, sky_dragon, titan_crab, old_man, fu_tou, yu_zheng]
        
    $ affectionMax = 100 #<-- maximum affection value is changed here
    $ HPmax = 1000
    $ SPmax = 750
    $ show_profiles = False
    $ viewing = "[uname!t]" #<-- the default character to show when the info screen is first called
    
screen profile_screen:
     tag menu
     zorder 10 
     for i in allchars:
            $ char = i
            if viewing == char.name: 
               $ name = "Name:\n " + char.name
               $ cname = "Chinese Name:\n " + char.cname
               $ age = "Age:\n " + char.age               
               $ family = "Family:\n " + char.family
               $ Element = "Element:\n " + char.Element
               $ 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
               $ HP = char.HP
               $ SP = char.SP


     window:
         background None
     
     frame: 
         align (0.5, 0.5)
         background None
         
         frame:
             align (0.5, 0.5)
             maximum (1250, 1000)
             yminimum 550
             background "box4.png"   
             
             vbox spacing 10: 
                 vbox xpos 1.3 ypos 3.7:
                   if name != 'Name: ???':
                      text name size 19
                 vbox xpos 1.3 ypos 3.7:
                   if cname != 'Chinese Name: ???':
                      text cname size 19
                 vbox xpos 1.3 ypos 3.7:
                   if age != 'Age: ???':
                      text age size 19                
                 vbox xpos 1.3 ypos 3.7:
                   if family != 'Family: ???':
                      text family size 19
                 vbox xpos 1.3 ypos 3.7:
                   if Element != 'Element: ???':
                      text Element size 19                      
                 vbox xpos 1.3 ypos 4.5:
                   if HP:
                       text "HP:" size 19
                       bar value HP range HPmax style "infoscreen_bar"
                 vbox xpos 1.3 ypos 4.4:
                   if SP:
                      text "SP:" size 19
                      bar value SP range SPmax style "infoscreen_bar" right_bar "menuspe.png" left_bar "menuspf.png"
             if pic != 'none':
                      add pic xalign 0.85 yalign 0.53 #Tinker with these numbers as needed to change where the image goes  
    
     textbutton "Return" background "closebutton.png" yalign 0.09 xalign 0.065 text_color "000000" text_hover_color "#CCCCCC" text_size 20 action [ Hide("profile_screen"), Return() ]
    
     frame xminimum 240 xmaximum 240 yminimum ymax: 
        style_group "infoscreen"  
        vbox yalign 0.5 xalign 5.6: 
            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 100 xmaximum 100 yminimum 10   
                   #code for future imagebuttons
                   #imagebutton idle "i.idlepic" hover "i.hoverpic" action SetVariable("viewing", i.name)
                $ i.normalizeAffection()
                $ i.normalizeHP()
                $ i.normalizeSP()
It should be like this:
before.jpg
But instead, this happens:
after.jpg
Someone please help me >.<

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Some things disappear when loading a saved game >.<

#4 Post by Anima »

You need to define the characters in the start instead of an init block.
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], bloodzy, Majestic-12 [Bot]