Ren'Py [SOLVED]Infinite Loop on Screen imagemap (or textbutton) action

GoldenD

Member
Sep 30, 2018
102
70
Hõla todos,
have a problem with an UI Screen
Python:
screen ui:

    zorder 105
.../...


# WEAPONS
    if len(Hero.weapons)>0:
        textbutton "{b}" + findWeaponName(Hero.weapons[0]) + "{/b}"   xpos 815    ypos 940:
            action listOfSpells[0].useSpell()
The problem is that my function listOfSpells[0].useSpell() does some datas update and finish with refreshing UI and then call screen UI.

What I don't understand is why renpy detects an infinite loop since I have not yet used the textbutton ?

If I replace my function by another which don't call screen ui, no problem.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
What I don't understand is why renpy detects an infinite loop since I have not yet used the textbutton ?
Because it's not how you call a code as reaction to a click.

With that
Code:
            action listOfSpells[0].useSpell()
Ren'py will call the useSpell method each time it build the screen, not when the player will click on the button.


What you want is the screen action :
Code:
            action Function( listOfSpells[0].useSpell )
Note that there's also no trailing "()". You pass the reference to the code, not it's result.


On a side note, Ren'py's infinite loop watchdog don't effectively detect infinite loops. It just stop the processing of the code if too much time separate the start of two "interactions". 99% of the time, it mean that there's an infinite loop, but time to time it just mean that you asked for something that take way too much time.
 
  • Like
Reactions: GoldenD

GoldenD

Member
Sep 30, 2018
102
70
Because it's not how you call a code as reaction to a click.

With that
Code:
            action listOfSpells[0].useSpell()
Ren'py will call the useSpell method each time it build the screen, not when the player will click on the button.


What you want is the screen action :
Code:
            action Function( listOfSpells[0].useSpell )
Note that there's also no trailing "()". You pass the reference to the code, not it's result.


On a side note, Ren'py's infinite loop watchdog don't effectively detect infinite loops. It just stop the processing of the code if too much time separate the start of two "interactions". 99% of the time, it mean that there's an infinite loop, but time to time it just mean that you asked for something that take way too much time.
Thanks AON,
it's ok for this example. Now what I really want, it's just a tooltip info on some areas of the screen on hovered event. I've tried with renpy tooltip but i encounter a real infinite loop and i think something in my code with displaying pictures is bad. So, i rewrite a sample code to show the problem.
Python:
label start:

    scene image("{}{}".format( PICTURES_INTERFACE, "background.png" ))

    show screen _screen01

    show expression "[PICTURES_INTERFACE]scroll.png"

    _Speaker "One Dialog..."

screen _screen01:

    zorder 105

    imagemap:
        ground  "[PICTURES_INTERFACE]ui.png"
        hover   "[PICTURES_INTERFACE]ui_hover.png"

        hotspot (85, 573, 169, 35) hovered ShowMenu()

        if len(Hero.weapons)>0:
            textbutton "{b}" + findWeaponName(Hero.weapons[0]) + "{/b}"   xpos 815    ypos 940:
                action ShowMenu()
If I use the textbutton, no problem.
But hovered in imagemap doesn't answer, doesn't display ui_hover.png...
I think it's a stupid detail buit i don't find.

Searching, I noticed that my scroll.png size was 1920*1080, like bkg and ui, so i've comment the show expression line. No change.

And if I think again, if the scroll picture was a problem, i suppose the textbutton would not work either.
 
Last edited: