Page 1 of 1

"Possible infinite loop" error on choice menu?

Posted: Mon Mar 02, 2020 9:42 am
by chesarty
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?

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

Posted: Mon Mar 02, 2020 11:58 am
by RicharDann
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.

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

Posted: Mon Mar 02, 2020 2:23 pm
by chesarty
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.