Screen button click not registering?

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
strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Screen button click not registering?

#1 Post by strayerror »

Disclaimer, I'm sure I'm doing something wonderfully daft, but I can't see it, time to call in the big-guns!

The code below is little more than a call screen with a single button intended to update a list item, however when coming from the Example dialogue line, the button ignores the first click. At first I thought I'd missed a restart_interaction but the Function action takes care of that automatically (and adding an explicit one doesn't alter the behaviour). The weird part is that reloading the game (Shift+R) while on the screen means it only needs one click, it's only when the player moves from the dialogue line to the screen that this occurs.

Code: Select all

label start:
    scene black
    'Example'
    call screen test()
    'Return Value: [_return!r]'
    return

screen test():
    default seq = [None]

    vbox:
        align .5, .5
        spacing 10

        text 'Why does the button below require two clicks?'

        text 'Value: {{color=f999}}{!r}{{/color}}'.format(seq) align .5, .5

        null

        imagebutton:
            align .5, .5
            xysize (100, 100)
            idle Solid('ff9')
            hover Solid('fc9')
            action Function(seq.__setitem__, 0, True)

        textbutton 'Exit screen' action Return(seq) align .5, .5
Help and ideas very welcome, thanks for reading!

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Screen button click not registering?

#2 Post by philat »

Yeah, that's weird. Don't know what's up. That said, it appears you can bypass the problem by using SetDict, if that's all you needed.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Screen button click not registering?

#3 Post by gas »

You call the screen.
So, the Function do his job and return a None. If you return a None, nothing happen (no value is stored in _return to proceed).
The second click simply check the button is active, so practically return True.
The fact that seq is the value you want for is a false positive (it was set on the first use of Function).
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Screen button click not registering?

#4 Post by strayerror »

philat wrote: Sun Jan 12, 2020 9:26 pm Yeah, that's weird. Don't know what's up. That said, it appears you can bypass the problem by using SetDict, if that's all you needed.
Thanks! Using SetDict does cover this case, but reading the code doesn't seem to yield any hint as to why one works and the other does not. :/
gas wrote: Sun Jan 12, 2020 10:10 pm You call the screen.
So, the Function do his job and return a None. If you return a None, nothing happen (no value is stored in _return to proceed).
The second click simply check the button is active, so practically return True.
The fact that seq is the value you want for is a false positive (it was set on the first use of Function).
The issue isn't the return value, that's included only as an illustration that the value doesn't appear to update if you click once and exit. The issue is that the "Value" text on the screen should update on the first click (because it should update the value and return None as you point out and Function has an implicit call to restart_interaction), but it does not until the second click.

I'm also at a loss as to how the code path for SetDict works, yet Function does not, but I'm hoping it's just a case of tired brain! Thanks again both! :P

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Screen button click not registering?

#5 Post by philat »

Yeah, I couldn't really figure it out either. It works either if you put the default outside the screen (so it's a regular variable rather than a screen variable) OR if you use SetDict, but I don't really see why Function and SetDict would differ in how they treat screen variables. Can't really help on why, as it goes a level deeper than I'm familiar with in terms of renpy's inner workings, but at least it's relatively easy to work around.

Post Reply

Who is online

Users browsing this forum: Google [Bot]