Game loops infinitely & never ends [SOLVED]

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
sasquatchii
Miko-Class Veteran
Posts: 552
Joined: Fri Jul 04, 2014 7:48 am
Completed: A Day in the Life of a Slice of Bread
Deviantart: sasquatchix
Soundcloud: sasquatchii
itch: sasquatchii
Location: South Carolina
Contact:

Game loops infinitely & never ends [SOLVED]

#1 Post by sasquatchii »

Hello,

I am working on a game right now in which players are run through a series of choices. They will have to play through each choice on the menu example below, but they get to pick which order they play through them in.

Image

However, I've run into this weird thing where, once all of the choices have been chosen, it keeps looping over and over again, specifically on the 'home' option, and never ends. Can someone help me figure out why? Here is the code I'm using:

Code: Select all

# Declare characters used by this game.

define laika = Character('', color="#c8ffc8", image="laika")
image laika = "images/gui/none.png"
image side laika = "images/characters/laikaneutral.png"

define laikas = Character('', color="#c8ffc8", image="laikas")
image laikas = "images/gui/none.png"
image side laikas = "images/characters/laikasniff.png"


define laikasc = Character('', color="#c8ffc8", image="laikasc")
image laikasc = "images/gui/none.png"
image side laikasc = "images/characters/laikascared.png"

define laikad = Character('', color="#c8ffc8", image="laikad")
image laikad = "images/gui/none.png"
image side laikad = "images/characters/laikadizzy.png"

label splashscreen:
    scene black
    with Pause(1)
    
    show splash with dissolve
    with Pause (2.3)
    
    scene bg darkpurple with dissolve
    with Pause (.5)
    
    return

# You can place the script of your game in this file.


# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

image splash = "images/backgrounds/laika-splash-screen.png"
image bg darkpurple = "images/backgrounds/dark-purple-bg.png"

#choices defaults

default choices_text = "I'm in a small place. No way to get out."
default thinking_text = "I should think about something else right now."
default smell_action_done = False
default look_action_done = False
default feel_action_done = False
default move_action_done = False
default home_action_done = False
default trip_action_done = False
default noise_action_done = False
default _game_menu_screen = 'pause_menu'

# The game starts here.
label start:
    
    stop music fadeout 1.1
    scene bg darkpurple with dissolve


label choices:
    
    # this checks to see if *all* actions are done. If they are, jump to the think menu instead
    if smell_action_done and look_action_done and feel_action_done and move_action_done:
        jump think
        
    menu:
        laika "[choices_text]"
        "Smell" if smell_action_done == False:
            $ smell_action_done = True
            $ choices_text = "What should I do now?"
            jump smell_action
        "Look" if look_action_done == False:
            $ look_action_done = True
            $ choices_text = "What should I do now?"
            jump look_action
        "Feel" if feel_action_done == False:
            $ feel_action_done = True
            $ choices_text = "What should I do now?"
            jump feel_action
        "Move" if move_action_done == False:
            $ move_action_done = True
            $ choices_text = "What should I do now?"
            jump move_action

label smell_action:
    laikas "This place smells mostly like me."
    laika "I smell urine too. It's mine."
    laikad "It's hot in here and I don't feel good. {p}I have been panting ever since the big noise."
    jump choices
    
label look_action:
    laika "It's dark. I can't see much. I think it's night time."
    laika "There's no one else here."
    laika "All I can see is the small window in front of me."
    laika "Outside the window is a big blue ball."
    laika "It's bright, the only bright thing I've seen today."
    jump choices
    
label feel_action:
    laika "The bed I'm in is hard and small."
    laika "I think there is something behind me, my tail has touched it." 
    laika "But I can't turn around to check."
    laika "When I lie down, I notice two strange things next to my head. They are cold and metallic."
    laika "When I lick the strange thing a tiny piece of food comes out." 
    laika "Water comes out of the other thing. It's not a lot, but I feel better."
    laika "When I turn my head, it feels like something is stuck to me." 
    laika "I really want to scratch at it so it goes away, but my leg won't reach it."
    laika "I hope it goes away soon. INSERT SAD PUPPY WHINE SOUND CLIP HERE"
    jump choices    
    
label move_action:
    laika "I can't move." 
    laika "I can sit and stand... {p}but I can't turn around to circle the bed or lie down."
    jump choices 

    
if home_action_done and trip_action_done and noise_action_done and move_action_done:
    jump credits

menu think:
    laikasc "[thinking_text]"
    "Home" if home_action_done == False:
            $ home_action_done = True
            $ thinking_text = "I should think about something else right now."
            jump home
    "The trip out" if trip_action_done == False:
            $ trip_action_done = True
            $ thinking_text = "I should think about something else right now."
            jump trip
    "The Big Noise" if noise_action_done == False:
            $ noise_action_done = True
            $ thinking_text = "I should think about something else right now."
            jump noise
        
label home:
    laikasc "I remember my old home."
    laikasc "A long time ago, I lived in another place."
    laikasc "The place I lived was far away from humans, I almost never saw them."
    laikasc "My old home was surrounded by trees, water, fields, and lots of other animals."
    laikasc "It was safe there."
    laikasc "The humans that I sometimes saw would come through during the day. Most of the time they were alone, or in small packs."
    laikasc "But they never came in crowds, which was good. Crowds are dangerous."
    laikasc "Thats why I stayed away from the places with so many humans."
    laikasc "Some dogs I know went to the city because there was more food, and that life was easier there."
    laikasc "That may or may not be true."
    laikasc "But the dogs that I knew that went to the city never came back."
    laikasc "When I was a pup, I lived in my old home with my mother, brothers, and sisters. There were many in our pack."
    laikasc "We'd run together, hunting for food, finding fun and exciting things."
    laikasc "There were bad times, sometimes, but also good times."
    laikasc "I loved living at my old home."
    jump think
    
    
label trip:
    laikasc "I remember my old home."
    laikasc "I should think about something else..."
    jump think

label noise:
    laikasc "I remember my old home."
    laikasc "I should think about something else..."
    jump think
    
call credits from _call_credits
return

label credits:
    image splash2 = Text("{size=90}Company Name", text_align=0.5, ypos=0.5) #Placeholder code if you don't have anything to use as a splash image or are just pure lazy.
#    image splash2 = "images/Company-Logo.png" #This is usually going to be located in an init block executed early in the code to show it when the game loads up as a splash screen.
#    image cred = Text(credits_s, font="myfont.ttf", text_align=0.5) #use this if you want to use special fonts
    image cred = Text(credits_s, text_align=0.5)
    image theend = Text("{size=80}The End", text_align=0.5)
    image thanks = Text("{size=80}Thanks for Playing!", text_align=0.5)
    $ credits_speed = 25 #scrolling speed in seconds
    scene black #replace this with a fancy background
    show cred at Move((0.5, 5.0), (0.5, 0.0), credits_speed, repeat=False, bounce=False, xanchor="center", yanchor="bottom")
    show theend:
        yanchor 0.5 ypos 0.5
        xanchor 0.5 xpos 0.5
    with dissolve
    with Pause(5)
    hide theend
    with dissolve
    with Pause(credits_speed - 5)
    show splash2
    with dissolve
    with Pause(3)
    hide splash2
    with dissolve
    with Pause(1)
    show thanks:
        yanchor 0.5 ypos 0.5
        xanchor 0.5 xpos 0.5
    with dissolve
    with Pause(4)
    hide thanks
    with dissolve
    return

init python:
    credits = ('Backgrounds', 'Airgoof'), ('Backgrounds', 'Dorktwerp'), ('Sprites and CG', 'Ballclown'), ('GUI', 'Cuddlywad'), ('Writing', 'Dorktwerp'), ('Writing', 'Fingerpookie'), ('Programming', 'Dorktwerp'), ('Music', 'Grumblemuck'), ('Music', 'Headwookum')
    credits_s = "{size=80}Game Title or Logo\n\n"
    c1 = ''
    for c in credits:
        if not c1==c[0]:
            credits_s += "\n{size=60}" + c[0] + "\n"
        credits_s += "{size=40}" + c[1] + "\n"
        c1=c[0]
    credits_s += "\n{size=60}Engine\n{size=40}" + renpy.version()
Any help or ideas would be much appreciated!
Last edited by sasquatchii on Wed Jul 19, 2017 4:43 am, edited 1 time in total.
ImageImage

User avatar
xxmissarichanxx
Regular
Posts: 87
Joined: Thu Jul 11, 2013 1:37 am
Completed: Froot Basket Valentine, Devious
Projects: After-Party Chemistry, The Salaryman
Tumblr: xxmissarichanxx
Deviantart: xxmissarichanxx
itch: xxmissarichanxx
Location: US
Contact:

Re: Game loops infinitely & never ends

#2 Post by xxmissarichanxx »

Hello! I was having this problem earlier this year too. It was because I used a "call" command and I never "return"ed to the original script.
I see you used "call" at least once in the script you provided above. I also found 2 "return" commands. Maybe removing one of them will help solve the problem? I'm not sure which to remove though...

Hopefully it helps!

Edit:
If it helps, the first "return" was used directly after you called the credits label. The second "return" was used under the credits label.

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Game loops infinitely & never ends

#3 Post by Scribbles »

removed

never mind that isn't even what you're asking lol -- I still don't see why your return wouldn't work though... are you using editra? sometimes the returns turn black (instead of orange) and they stop working?? sounds weird but you could check that.
Image - Image -Image

User avatar
Natalie
Newbie
Posts: 17
Joined: Thu Jun 16, 2016 10:50 pm
Projects: Serment - Contract with a Devil
Contact:

Re: Game loops infinitely & never ends

#4 Post by Natalie »

You should probably move this

Code: Select all

call credits from _call_credits
return
to before the "home" label.

So, the code should be like this:

Code: Select all

menu think:
    ...

call credits from _call_credits
return

label home:
    ...
What's happening here is that after all the choices have been chosen, the "think" label (menu think) is now empty. The code will then proceed to what's directly below it, which is currently the "home" label, making it loop forever.
Image
Follow Serment (JRPG dungeon crawler/Visual Novel hybrid) on Steam!

User avatar
sasquatchii
Miko-Class Veteran
Posts: 552
Joined: Fri Jul 04, 2014 7:48 am
Completed: A Day in the Life of a Slice of Bread
Deviantart: sasquatchix
Soundcloud: sasquatchii
itch: sasquatchii
Location: South Carolina
Contact:

Re: Game loops infinitely & never ends

#5 Post by sasquatchii »

Natalie wrote:You should probably move this

Code: Select all

call credits from _call_credits
return
to before the "home" label.

So, the code should be like this:

Code: Select all

menu think:
    ...

call credits from _call_credits
return

label home:
    ...
What's happening here is that after all the choices have been chosen, the "think" label (menu think) is now empty. The code will then proceed to what's directly below it, which is currently the "home" label, making it loop forever.
That worked!! Thank you so much!

Also, thanks Scribbles & xxmissarichanxx for your help as well :)
ImageImage

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot]