"Possible infinite loop" error on choice menu?

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
chesarty
Regular
Posts: 100
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

"Possible infinite loop" error on choice menu?

#1 Post by chesarty » Mon Mar 02, 2020 9:42 am

Hey all! I programmed the first choices into the game and wanted to make the menu options disappear once you've been through that option. Everything works splendid up until all options have been through and the game should jump to the next scene. The game lags out (not responding) and then this shows up:

```
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 168, in script
jump choice1 #if menuset doesn't have enough length, go back to menu
Exception: Possible infinite loop.

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

Full traceback:
File "game/script.rpy", line 168, in script
jump choice1 #if menuset doesn't have enough length, go back to menu
File "C:\Users\Ches\Downloads\renpy-7.3.5-sdk\renpy\execution.py", line 59, in check_infinite_loop
raise Exception("Possible infinite loop.")
Exception: Possible infinite loop.

Windows-8-6.2.9200
Ren'Py 7.3.5.606
LOVESICK 1.0
Mon Mar 02 15:39:28 2020
```


I understand the reasoning behind it, but I've done it in a way that should make the transition seamless, using another tutorial that has worked well before.

Code: Select all

menu choice1:
    set menuset
    "Where should I head to next?"
    
    "Explore school grounds":
        jump explore_school_grounds
        
    "Go back inside":
        jump back_inside
        
    "Go to the cafeteria":
        jump cafeteria
    
if len(menuset) == 3: #number of possibilities
    $menuset = set() #I guess you'd need to reset to 0 or use different variable set to use this trick somewhere else
    jump scene2 #name of your label after events
else:
    jump choice1 #if menuset doesn't have enough length, go back to menu 
I wonder what's wrong?

User avatar
RicharDann
Veteran
Posts: 255
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: "Possible infinite loop" error on choice menu?

#2 Post by RicharDann » Mon Mar 02, 2020 11:58 am

The if statement is likely causing the problem. But do you really need it?

If you do something like this in all three labels:

Code: Select all

label explore_school_grounds:

    "I'll explore the school for a bit."
    
    jump choice1 

And add the jump to the next scene right after the menu:

Code: Select all

menu choice1:
    set menuset
    "Where should I head to next?"
        
    "Explore school grounds":
        jump explore_school_grounds
      
jump scene2
You'll probably won't need that if statement. Ren'Py will automatically skip the menu once it sees there are no more options left.
The most important words a man can say are, “I will do better”.
The most important step is always the next one.

User avatar
chesarty
Regular
Posts: 100
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: "Possible infinite loop" error on choice menu?

#3 Post by chesarty » Mon Mar 02, 2020 2:23 pm

RicharDann wrote:
Mon Mar 02, 2020 11:58 am
The if statement is likely causing the problem. But do you really need it?

If you do something like this in all three labels:

Code: Select all

label explore_school_grounds:

    "I'll explore the school for a bit."
    
    jump choice1 

And add the jump to the next scene right after the menu:

Code: Select all

menu choice1:
    set menuset
    "Where should I head to next?"
        
    "Explore school grounds":
        jump explore_school_grounds
      
jump scene2
You'll probably won't need that if statement. Ren'Py will automatically skip the menu once it sees there are no more options left.
Oh, that fixed it! Thank you ^^ Glad that it was an easy fix.

Post Reply

Who is online

Users browsing this forum: No registered users