Page 1 of 1

[Solved] Exception: Possible infinite loop

Posted: Fri Jul 23, 2021 7:22 pm
by apexchimps
Hi,

We are developing a game in which sometimes the game is waiting for the player to click something. The way we managed to do this is by using a while-true-pause scheme. It has worked in previous games and even in this one until recently. This error appears:

Image

The underlying code is the following:

Code: Select all

label navegacion:
    $flag_boton = True
    $flag_navegacion_activa = True

    while True:
        $ renpy.pause(200, hard=True)
This has worked for years. If we click Ignore in the error page the game continues smoothly. We would like (if possible) to just continue without the error. Is it possible?

We have tried unsuccesfully:
- to use a try-except
- to delete the while-true and use a jump to the beginning
- to fool the while True

Any ideas?

Thank you in advance!

Re: Exception: Possible infinite loop

Posted: Fri Jul 23, 2021 7:49 pm
by hell_oh_world
try

Code: Select all

default playing = true

label start:
  while playing:
    pass 
not sure though, never used this kind of method before. I wouldn't suggest doing it either since renpy itself is already running on an infinite loop to make the game work.
If you're monitoring something, use periodic callbacks or screens.

Re: Exception: Possible infinite loop

Posted: Sat Jul 24, 2021 3:23 am
by Ocelot
How about forcing interaction instead of using pause with a timeout? Maybe with a jump back if there are buttons which do not jump in different parts of script?

Re: Exception: Possible infinite loop

Posted: Sat Jul 24, 2021 4:09 am
by Alex
apexchimps wrote: Fri Jul 23, 2021 7:22 pm

Code: Select all

label navegacion:
    $flag_boton = True
    $flag_navegacion_activa = True

    while True:
        $ renpy.pause(200, hard=True)
Try

Code: Select all

label navegacion:
    $flag_boton = True
    $flag_navegacion_activa = True

    $ renpy.pause(hard=True)
or

Code: Select all

label navegacion:
    $flag_boton = True
    $flag_navegacion_activa = True

    $ ui.interact()
https://www.renpy.org/doc/html/screen_p ... i.interact

Re: Exception: Possible infinite loop

Posted: Sat Jul 24, 2021 8:45 am
by apexchimps
Thank you for your quick answers, hell_oh_world, Ocelot and Alex!

I have tried your solutions and I was able to solve it! In the end it has been a mixture of Ocelot's #1 solution and Alex's #1 solution.

By removing the while-true and leaving just the pause (thanks Alex!) it worked almost right, but one button returned to the main menu. That is where Ocelot's answer kicks in. This button wasn't jumping appropriately. So thanks Ocelot!

Code: Select all

label navegacion:
    $flag_boton = True
    $flag_navegacion_activa = True

    $ renpy.pause(hard=True)
    jump navegacion
Best regards!