Can someone find the 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
briannavon
Miko-Class Veteran
Posts: 505
Joined: Mon Mar 26, 2012 6:51 pm
Location: Philadelphia
Contact:

Can someone find the error?

#1 Post by briannavon » Sun Sep 29, 2013 3:17 pm

I am having a problem with this code I'm using to teach someone. When I have this fight scene, it always choices the "get_hit" action and instead of either going back to the label or saying you won and going to another label, it ends the game. What is wrong?

Code: Select all

label fight_apple_monster_coven_forest :   
    show apple mad at center
    show screen mc_fight_screen
    show screen enemy_fight_screen
    call screen fight_main_choices
    if _return == "flee" :
        "You fled!"
        jump coven_forest
        
        
    if _return == "hit" :
        $ action = renpy.random.choice(['dodge', 'get_hit'])
        if action == "dodge" :
            if enemy_dodge >= dodge :
                show apple mad at right with move
                "It dodged your attack!"
                show apple mad at center with move
                $ action = renpy.random.choice(['dodge', 'get_hit'])
                if action == "dodge" :
                    if enemy_dodge <= dodge :
                      "You dodged it's attack!"
                      jump fight_apple_monster_coven_forest
                    
                    if enemy_dodge > dodge :
                       "It attacked you!"
                       $ hp -= enemy_attack
                       if hp <= 0 :
                          $ hp = 0
                          "You were defeated!"
                          scene black with dissolve
                          jump clinic_lost_fight
                        
                       if hp > 0 :
                          jump fight_apple_monster_coven_forest
                if action == "get_hit" :
                     $ action = renpy.random.choice(['normal', 'spin'])
                     if action == "normal" :
                         "It attacked you!"
                         $ hp -= enemy_attack 
                         if hp <= 0 :
                             $ hp = 0
                             "You were defeated!"
                             scene black with dissolve
                             jump clinic_lost_fight
                        
                         if hp > 0 :
                             jump fight_apple_monster_coven_forest 
                     if action == "spin" :
                         show apple spin at center
                         "It performed a spin attack!"
                         $ hp -= ("enemy_attack" + 3)
                         if hp <= 0 :
                             $ hp = 0
                             "You were defeated!"
                             scene black with dissolve
                             jump clinic_lost_fight
                        
                         if hp > 0 :
                             jump fight_apple_monster_coven_forest   
                         
                         
                    
            if enemy_dodge < dodge : 
                mon "Eeeeee!"
                "You attacked it!"
                $ enemy_hp -= attack
                if enemy_hp <= 0 :
                    hide apple mad with dissolve
                    "You defeated it!"
                    $ xp += 5
                    jump xp_gained
                    
                if enemy_hp > 0 :
                  $ action = renpy.random.choice(['dodge', 'get_hit'])
                  if action == "dodge" :
                    if enemy_dodge >= dodge :
                      show apple mad at right with move
                      "It dodged your attack!"
                      show apple mad at center with move
                      $ action = renpy.random.choice(['dodge', 'get_hit'])
                      if action == "dodge" :
                         if enemy_dodge <= dodge :
                            "You dodged it's attack!"
                            jump fight_apple_monster_coven_forest
                    
                         if enemy_dodge > dodge :
                             "It attacked you!"
                             $ hp -= enemy_attack
                             if hp <= 0 :
                                 $ hp = 0
                                 "You were defeated!"
                                 scene black with dissolve
                                 jump clinic_lost_fight
                        
                             if hp > 0 :
                                 jump fight_apple_monster_coven_forest
                      if action == "get_hit" :
                         $ action = renpy.random.choice(['normal', 'spin'])
                         if action == "normal" :
                            "It attacked you!"
                            $ hp -= enemy_attack 
                            if hp <= 0 :
                              $ hp = 0
                              "You were defeated!"
                              scene black with dissolve
                              jump clinic_lost_fight
                        
                            if hp > 0 :
                                jump fight_apple_monster_coven_forest 
                         if action == "spin" :
                                 show apple spin at center
                                 "It performed a spin attack!"
                                 $ hp -= ("enemy_attack" + 3)
                                 if hp <= 0 :
                                    $ hp = 0
                                    "You were defeated!"
                                    scene black with dissolve
                                    jump clinic_lost_fight
                        
                                 if hp > 0 :
                                         jump fight_apple_monster_coven_forest   
                            
                    
                    
                    
                
                
        if action == "get_hit" :    
                mon "Eeeeee!"
                "You attacked it!"
                $ enemy_hp -= attack
                if enemy_hp <= 0 :
                    hide apple mad with dissolve
                    "You defeated it!"
                    $ xp += 5
                    jump xp_gained
                    
                if enemy_hp > 0 :
                    
                  $ action = renpy.random.choice(['dodge', 'get_hit'])
                  if action == "dodge" :
                    if enemy_dodge >= dodge :
                      show apple mad at right with move
                      "It dodged your attack!"
                      show apple mad at center with move
                      $ action = renpy.random.choice(['dodge', 'get_hit'])
                      if action == "dodge" :
                         if enemy_dodge <= dodge :
                            "You dodged it's attack!"
                            jump fight_apple_monster_coven_forest
                    
                         if enemy_dodge > dodge :
                             "It attacked you!"
                             $ hp -= enemy_attack
                             if hp <= 0 :
                                $ hp = 0
                                "You were defeated!"
                                scene black with dissolve
                                jump clinic_lost_fight
                        
                             if hp > 0 :
                                 jump fight_apple_monster_coven_forest
                      if action == "get_hit" :
                         $ action = renpy.random.choice(['normal', 'spin'])
                         if action == "normal" :
                            "It attacked you!"
                            $ hp -= enemy_attack 
                            if hp <= 0 :
                              $ hp = 0
                              "You were defeated!"
                              scene black with dissolve
                              jump clinic_lost_fight
                        
                            if hp > 0 :
                                jump fight_apple_monster_coven_forest 
                         if action == "spin" :
                                 show apple spin at center
                                 "It performed a spin attack!"
                                 $ hp -= ("enemy_attack" + 3)
                                 if hp <= 0 :
                                    $ hp = 0
                                    "You were defeated!"
                                    scene black with dissolve
                                    jump clinic_lost_fight
                        
                                 if hp > 0 :
                                         jump fight_apple_monster_coven_forest   
                            
                    
                          
                       
                
Join Me At LivingGame Productions!

http://livinggameproductions.blogspot.com/

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: Can someone find the error?

#2 Post by Ayutac » Sun Sep 29, 2013 5:09 pm

First guess would be the screen fight_main_choices you didn't post. People a likely to see it to help you on this matter.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

briannavon
Miko-Class Veteran
Posts: 505
Joined: Mon Mar 26, 2012 6:51 pm
Location: Philadelphia
Contact:

Re: Can someone find the error?

#3 Post by briannavon » Sun Sep 29, 2013 5:36 pm

Oh, I'm sorry! Here it is :

Code: Select all

screen fight_main_choices :
    frame xalign 0.0 yalign 0.8 :
        hbox :
            textbutton "Hit" action Return('hit')
            textbutton "Use Magic" action [ Hide('fight_main_choices') , Show('fight_magic_choices') ]
            textbutton "Use Items" action [ Hide('fight_main_choices') , Show('fight_item_choices') ]
            textbutton "Flee" action Return('flee')
Join Me At LivingGame Productions!

http://livinggameproductions.blogspot.com/

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Can someone find the error?

#4 Post by xela » Sun Sep 29, 2013 6:55 pm

Consider teaching that someone some elif/else statements while at it :roll: Your code confused even yourself, how is your poor pupil supposed to feel :?:

Absence of "get_hit" fork for "get_hit" branch and ("enemy_attack" + 3) also require your attention.
Last edited by xela on Sun Sep 29, 2013 7:04 pm, edited 1 time in total.
Like what we're doing? Support us at:
Image

briannavon
Miko-Class Veteran
Posts: 505
Joined: Mon Mar 26, 2012 6:51 pm
Location: Philadelphia
Contact:

Re: Can someone find the error?

#5 Post by briannavon » Sun Sep 29, 2013 7:04 pm

xela wrote:Consider teaching them some elif/else statements while at it :roll:

Bad indentation on last "get_hit" and ("enemy_attack" + 3) also require your attention.
Oh sorry about that! Usually I know better but I was kinda rushing. :oops:

Anyway, I will see if changes those helps!
Join Me At LivingGame Productions!

http://livinggameproductions.blogspot.com/

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Can someone find the error?

#6 Post by xela » Sun Sep 29, 2013 7:06 pm

briannavon wrote:
xela wrote:Consider teaching them some elif/else statements while at it :roll:

Bad indentation on last "get_hit" and ("enemy_attack" + 3) also require your attention.
Oh sorry about that! Usually I know better but I was kinda rushing. :oops:

Anyway, I will see if changes those helps!
It wasn't bad ident, whole codeblock seems to be missing***
Like what we're doing? Support us at:
Image

briannavon
Miko-Class Veteran
Posts: 505
Joined: Mon Mar 26, 2012 6:51 pm
Location: Philadelphia
Contact:

Re: Can someone find the error?

#7 Post by briannavon » Sun Sep 29, 2013 7:17 pm

xela wrote:
briannavon wrote:
xela wrote:Consider teaching them some elif/else statements while at it :roll:

Bad indentation on last "get_hit" and ("enemy_attack" + 3) also require your attention.
Oh sorry about that! Usually I know better but I was kinda rushing. :oops:

Anyway, I will see if changes those helps!
It wasn't bad ident, whole codeblock seems to be missing***
OK, then. Can you help me find where I forgot to put code at? :D

P.S. : Thank you for dealing with my stupidity :oops:
Join Me At LivingGame Productions!

http://livinggameproductions.blogspot.com/

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Can someone find the error?

#8 Post by xela » Sun Sep 29, 2013 7:38 pm

Just switch to else and code should become more readable:

Code: Select all

        if action == "get_hit" :    
                mon "Eeeeee!"
                "You attacked it!"
                $ enemy_hp -= attack

                if enemy_hp <= 0 :
                    hide apple mad with dissolve
                    "You defeated it!"
                    $ xp += 5
                    jump xp_gained
                    
                else:
                  $ action = renpy.random.choice(['dodge', 'get_hit'])
                  if action == "dodge" : # Ident 18 
                    if enemy_dodge >= dodge :
                      show apple mad at right with move
                      "It dodged your attack!"
                      show apple mad at center with move
                      $ action = renpy.random.choice(['dodge', 'get_hit'])
                      if action == "dodge" : # Ident 22
                         if enemy_dodge <= dodge :
                            "You dodged it's attack!"
                            jump fight_apple_monster_coven_forest
                    
                         else:
                             "It attacked you!"
                             $ hp -= enemy_attack
                             if hp <= 0 :
                                $ hp = 0
                                "You were defeated!"
                                scene black with dissolve
                                jump clinic_lost_fight
                        
                             else:
                                 jump fight_apple_monster_coven_forest
                      else: # Ident 22
                         $ action = renpy.random.choice(['normal', 'spin'])
                         if action == "normal" :
                            "It attacked you!"
                            $ hp -= enemy_attack 
                            if hp <= 0 :
                              $ hp = 0
                              "You were defeated!"
                              scene black with dissolve
                              jump clinic_lost_fight
                        
                            else:
                                jump fight_apple_monster_coven_forest 
                         else:
                                 show apple spin at center
                                 "It performed a spin attack!"
                                 $ hp -= (enemy_attack + 3)
                                 if hp <= 0 :
                                    $ hp = 0
                                    "You were defeated!"
                                    scene black with dissolve
                                    jump clinic_lost_fight
                        
                                 else:
                                         jump fight_apple_monster_coven_forest
                                         
                 else:
                     # Add codeblock that covers "get_hit" at ident 18.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_