Need to click twice to advance in certain dialogue

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
Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Need to click twice to advance in certain dialogue

#1 Post by Adrian_DVL »

Hi mates!

I've got a weird issue regarding a dialogue. See, I have a label like this:

Code: Select all

label aim_memo:
    $ ni+=1
    $ act = aim.id
    $ aim.ene -= 1
    $ memtotalp = 0
    if aim.lvl == 0:
        $ mst = 1
    elif aim.lvl == 1:
        $ mst = 2
    elif aim.lvl == 2:
        $ mst = 3
    if aim.lvl == 0:
        z "You want me to help ya with a song?"	### <-- HERE'S THE DAMN PROBLEM!
    elif aim.lvl == 1:
        z "lvl2"
    elif aim.lvl == 2:
        z "lvl3"
    stop music
    stop sound
    if renpy.seen_label("memo"):
        pass
    else:
        call memotuto
    image mi = "story/aimx[aim.lvl]_[memtotalp].jpg"
    scene mi with di
    call memo
    ...
Memo is a label that contains a minigame, which contains a couple screens, but I believe that's not relevant here.
The thing is that 'aim' is reaching this label with its 'lvl' parameter set to 0, and, indeed, when I trigger this label, I get the correct dialogue: "You want me to help ya with a song?". BUT when I click once again, nothing happens! That line of code is still executing or rather, it's executed again. I have to click again for the game to advance and finally call the memo label. All the rest is working fine.

What surprises me the most is that when I trigger this label and get that line of dialogue and I press Shift+E in the game, my code editor indicates that it's executing that line of dialogue. Then, if I mouse click once more in the game and press Shift+E again, the code editor says that it's executing the SAME line of dialogue, as if I didn't click at all!
Another odd thing is that, once I've done that, if I scroll up with my mouse to rollback the game to before this label and I trigger the label again, everything works fine, I only have to click once and the memo label is called normally.

Does anyone know what's happening here? I could drop here the code for the memo label, but I really think that's not relevant at all, as it's as if that line of dialogue is repeating twice for some reason!

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Need to click twice to advance in certain dialogue

#2 Post by Milkymalk »

Where is aim.lvl changed and under which conditions? It looks like the line is indeed executed twice but not twice at once. I think the game advances, loops back to the label, and executes it again.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Need to click twice to advance in certain dialogue

#3 Post by Adrian_DVL »

Milkymalk wrote: Tue Apr 28, 2020 8:12 am Where is aim.lvl changed and under which conditions? It looks like the line is indeed executed twice but not twice at once. I think the game advances, loops back to the label, and executes it again.
aim.lvl is changed winning a minigame. Once the minigame (the label memo) is successfully finished, it jumps to this label:

Code: Select all

label memo_game_win:
    $ memo_finish = True
    $ renpy.pause (0.1, hard = True)
    stop music
    play sound win
    hide screen before_scr
    hide screen memo_scr
    $ _game_menu_screen = "preferences"
    $ mempoints = 0
    $ memgoodp = 0
    $ membadp = 0
    $ songs += 1
    $ win = True
    $ renpy.pause (0.1, hard = True)
    $ renpy.block_rollback()
    ...
    	elif act == "aim":
    		jump aim_win
    ...
Then, that one jumps to this one:

Code: Select all

label aim_win:
    if aim.lvl == 0:
        scene aimx0_20
    elif aim.lvl == 1:
        scene aimx1_20
    elif aim.lvl == 2:
        scene aimx2_20
    $ aim.pl = True
    $ renpy.block_rollback()
    hide screen lui
    hide screen lsb
    if aim.lvl < 6:
        $ aim.lvl += 1
    if aim.lvl == 1:
        jump aim1
    elif aim.lvl == 2:
        jump aim2
    elif aim.lvl == 3:
        jump aim3
    elif aim.lvl == 4:
        jump aim4
    elif aim.lvl == 5:
        jump aim5
    elif aim.lvl == 6:
        jump aim6
Here's the only way to change lvl. Once aim1, aim2 or whatever is finished, the player would be able to trigger the first label, aim_memo, again, at any time, which would be triggered with lvl set to 1 or then to 2. Beyond that lvl, there'd be another label to trigger another minigame, which, once successfully finished would trigger this aim_win label too. I've not tested the other 'pre-minigame' label yet, but I presume it'd have the same dialogue issue.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Need to click twice to advance in certain dialogue

#4 Post by Milkymalk »

No clue, but I can give you tips for bug hunting: The python statement "print" outputs to the console which you can call up with SHIFT+O. When something like this happens, I place various print statements at critical points of my code to track the execution flow. Be aware that if you do that inside a screen, prediction may cause the statement to be executed more than once.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Need to click twice to advance in certain dialogue

#5 Post by Adrian_DVL »

Milkymalk wrote: Tue Apr 28, 2020 8:47 am No clue, but I can give you tips for bug hunting: The python statement "print" outputs to the console which you can call up with SHIFT+O. When something like this happens, I place various print statements at critical points of my code to track the execution flow. Be aware that if you do that inside a screen, prediction may cause the statement to be executed more than once.
Thank you so much for the tip! I've put it into practice and what i got didn't surprise me. I have the code like this:

Code: Select all

label aim_memo:
    image mi = "story/aimx[aim.lvl]_[memtotalp].jpg"
    $ ni+=1
    $ act = aim.id
    $ aim.ene -= 1
    $ memtotalp = 0
    python:
        print ("1")
    if aim.lvl == 0:
        $ mst = 1
    elif aim.lvl == 1:
        $ mst = 2
    elif aim.lvl == 2:
        $ mst = 3
    if aim.lvl == 0:
        python:
            print ("2")
        z "You want me to help ya with a song?"
        python:
            print ("3")
    elif aim.lvl == 1:
        z "lvl2"
    elif aim.lvl == 2:
        z "lvl3"
    stop music
    stop sound
    if renpy.seen_label("memo"):
        pass
    else:
        call memotuto
    scene mi with di
    call memo
    return
Now when I click the button that triggers this label, "1" and "2" appear at the same time in the console, while in the game, the line "You want me to help ya with a song?" is displayed. When I mouse click in the game again, literally NOTHING happens, neither in the console nor in the game. It's as if I didn't even click at all. Then, when I click again, "3" appears in the console and the label memo is called. I'm back where I started.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Need to click twice to advance in certain dialogue

#6 Post by Milkymalk »

So clicking the first time actually does not advance the game at all and no "3" appears in the console? That is strange, because there is absolutely no reason for this. Did you modify the "say" screen? I can't see any reason for the first click to be "swallowed" by the game.
At least we now know that it's not a faulty loop, but at the same time I'm at a total loss now :(
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Need to click twice to advance in certain dialogue

#7 Post by Adrian_DVL »

Milkymalk wrote: Tue Apr 28, 2020 9:12 am So clicking the first time actually does not advance the game at all and no "3" appears in the console? That is strange, because there is absolutely no reason for this. Did you modify the "say" screen? I can't see any reason for the first click to be "swallowed" by the game.
At least we now know that it's not a faulty loop, but at the same time I'm at a total loss now :(
I didn't modify the say screen, but now that you mention it, "z" is a special character whose dialogues are displayed at the bottom right corner. Here's the character:

Code: Select all

define z = Character("", what_text_align=0.5, what_xpos=950, what_ypos=122, what_yalign=0.5, what_xsize=640, what_min_width=640, what_font="Delius-Regular.ttf", what_size=26)
I should've mentioned it before, but I really don't see how this has anything to do with the issue, to be honest.

I did try to modify the say screen a while ago, but I didn't like it and I'm pretty sure I have it by default now:

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"


    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
EDIT: Another thing that I've done is remove the background to the window style, because I want the game to display the background only for the characters that I pass a background as an argument to. So my window style is this:

Code: Select all

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    background None
Changing this has no effect on my issue at all though.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Need to click twice to advance in certain dialogue

#8 Post by Alex »

Adrian_DVL wrote: Tue Apr 28, 2020 9:23 am ...
Since you've called 'memotuto' and 'memo' labels, check if game properly returned back from 'aim_win' or so label.

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Need to click twice to advance in certain dialogue

#9 Post by Adrian_DVL »

Alex wrote: Tue Apr 28, 2020 12:50 pm
Adrian_DVL wrote: Tue Apr 28, 2020 9:23 am ...
Since you've called 'memotuto' and 'memo' labels, check if game properly returned back from 'aim_win' or so label.
But the thing is that I'm not coming from any of those labels when I call this one. "memotuto" has nothing to do, I've already tested it removing that call. And "memo" is not called until AFTER the issue is presented. As you could see by the python prints, the issue is BEFORE the call to "memo".
Here's the flow, first of all, the player can click on a button with this action:

Code: Select all

action [Call("ed"), Stop("music"), Stop("sound"), Hide("gowith"), Hide("room"), (SetVariable("can", False)), Jump("{0}".format(rl.id))]
This button jumps to a label called aim, which is an object of the rl class:

Code: Select all

label aim:
    $ energy -= 1
    stop sound fadeout 1.0
    stop music fadeout 1.0
    $ ni = 0
    image aim = "story/aim[aim.lvl]_[ni].jpg"
    image aimg = "story/aim[aim.lvl]_g.jpg"
    if aim not in glist.met:
        $ glist.meet(aim)
        call aim_meet
        if tuto == False:
            call rltuto
        jump aim_hi

    else:
        jump aim_hi

    return
This jumps to aim_hi, which is like this:

Code: Select all

label aim_hi:
    if aim.lvl == 0:
        $ place = _("Aimee's apartment")
        $ mtime = _("15 minutes later")
        scene black
        show screen aft with fa
        $ renpy.pause(1.5)
        hide screen aft with fa
        scene aim with di
        show screen statsbar
        show screen lui(aim)
        show screen lsb(aim)
        play music "<from 0 to 129.75>audio/theme_aim.mp3"
        queue music theme_aim_l loop
        $ _skipping = False
        $ can = True
        z "So what do you wanna do, {color=#a99cff}[name]{/color}? Wanna talk about something?"
    return
Aclaration: "can" is a variable that, when True, adds to the screen lsb (which is showed at the moment that "can" is toggled) a huge invisible button, in order to prevent player from clicking on any other spot than the real buttons of the screen.
So now the player has to click a button. Here's the action of the one that we're talking about:

Code: Select all

action [(SetVariable("can", False)), Hide("girlsb"), Jump("{0}_memo".format(rl.id))]
And, finally, here's the label that we all know already:

Code: Select all

label aim_memo:
    image mi = "story/aimx[aim.lvl]_[memtotalp].jpg"
    $ ni+=1
    $ act = aim.id
    $ aim.ene -= 1
    $ memtotalp = 0
    python:
        print ("1")
    if aim.lvl == 0:
        $ mst = 1
    elif aim.lvl == 1:
        $ mst = 2
    elif aim.lvl == 2:
        $ mst = 3
    if aim.lvl == 0:
        python:
            print ("2")
        z "You want me to help ya with a song?"
        python:
            print ("3")
    elif aim.lvl == 1:
        z "lvl2"
    elif aim.lvl == 2:
        z "lvl3"
    stop music
    stop sound
    if renpy.seen_label("memo"):
        pass
    else:
        call memotuto
    scene mi with di
    call memo
    return
And that's it. Every other dialogue, of this "z" character and others, are displayed normally and everything else works fine.

EDIT: Okay, a little note on this one: as you surely know "memotuto" is a tutorial of the minigame, which is called only once, if "memotuto" has never been seen in the system before. Okay, turns out that if I delete persistent and go through this label again, the line of dialogue "You want me to help ya with a song?" is displayed normally, I only have to click once to advance and call "memotuto". But once "memotuto" is seen and thus, is never called again, the next time I call "aim_memo" the dialogue issue is there again and I need two mouse clicks to advance.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Need to click twice to advance in certain dialogue

#10 Post by Alex »

Adrian_DVL wrote: Tue Apr 28, 2020 1:14 pm ...EDIT: Okay, a little note on this one: as you surely know "memotuto" is a tutorial of the minigame, which is called only once, if "memotuto" has never been seen in the system before. Okay, turns out that if I delete persistent and go through this label again, the line of dialogue "You want me to help ya with a song?" is displayed normally, I only have to click once to advance and call "memotuto". But once "memotuto" is seen and thus, is never called again, the next time I call "aim_memo" the dialogue issue is there again and I need two mouse clicks to advance.
Looks like you've called 'ed' label by clicking button, then call some label and call some label from there... but never actually returned to main game flow. This might be the reason why you need to click several times (if like 'aim_memo' been called and then called again and first click returns player back to the place where this label was called first time, and only then click makes the game go farther). Try to test it somehow.

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Need to click twice to advance in certain dialogue

#11 Post by Adrian_DVL »

Alex wrote: Tue Apr 28, 2020 2:49 pm
Adrian_DVL wrote: Tue Apr 28, 2020 1:14 pm ...EDIT: Okay, a little note on this one: as you surely know "memotuto" is a tutorial of the minigame, which is called only once, if "memotuto" has never been seen in the system before. Okay, turns out that if I delete persistent and go through this label again, the line of dialogue "You want me to help ya with a song?" is displayed normally, I only have to click once to advance and call "memotuto". But once "memotuto" is seen and thus, is never called again, the next time I call "aim_memo" the dialogue issue is there again and I need two mouse clicks to advance.
Looks like you've called 'ed' label by clicking button, then call some label and call some label from there... but never actually returned to main game flow. This might be the reason why you need to click several times (if like 'aim_memo' been called and then called again and first click returns player back to the place where this label was called first time, and only then click makes the game go farther). Try to test it somehow.
Hmmm... I get your point. You mean that aim_memo is called twice due to the calls on the button. However, this can't be for a reason: if the label was called more than once, then my console would print "1" and "2" more than once, and it doesn't. Now I've tested it removing the "ed" and other superfluous calls with no success. I'm really starting to go crazy, haha
Another thing, I'm testing this without buttons. I mean, I'm testing it from the game prologue, where the game jumps directly to aim. So the flow is like this:
  • label start
  • label start -> call prologue
  • label prologue -> jump aim
  • label aim -> jump aim_hi
  • screen lsb within label aim_hi -> action [(SetVariable("can", False)), Hide("girlsb"), Jump("{0}_memo".format(girl.id))]
And that's it. There are no weird things as far as I see it.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Need to click twice to advance in certain dialogue

#12 Post by Alex »

Adrian_DVL wrote: Tue Apr 28, 2020 3:18 pm ...
What are the screens

Code: Select all

        show screen statsbar
        show screen lui(aim)
        show screen lsb(aim)
they seem to be never hided?
Any chance that you hide them by first click and only then can click to go farther in game?

And what's the screen 'girlsb' that you hiding by clicking the button?

Code: Select all

action [(SetVariable("can", False)), Hide("girlsb"), Jump("{0}_memo".format(rl.id))]

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Need to click twice to advance in certain dialogue

#13 Post by Adrian_DVL »

Alex wrote: Tue Apr 28, 2020 3:29 pm
Adrian_DVL wrote: Tue Apr 28, 2020 3:18 pm ...
What are the screens

Code: Select all

        show screen statsbar
        show screen lui(aim)
        show screen lsb(aim)
they seem to be never hided?
Any chance that you hide them by first click and only then can click to go farther in game?

And what's the screen 'girlsb' that you hiding by clicking the button?

Code: Select all

action [(SetVariable("can", False)), Hide("girlsb"), Jump("{0}_memo".format(rl.id))]
Nope, I'm not hiding anything by first click...
statsbar is a screen that is nearly always showed and it shows the player stats on a bar at the top of the screen. It only contains text and a few graphics.
lui is a screen that contains a banner that shows at the bottom of the screen and contains some graphics, some of them depending of the object of "rl" that is passed as a parameter.
lsb is a screen of like 2k lines of code that contains the buttons player can click and, basically, is the main interface for the player to trigger many labels, one of them, "aim_memo".
girlsb is a screen showing some graphics that is used by lui, but which I want to hide without hiding the whole lui by clicking that button.

I still can't think of a reason why Renpy is swallowing my click on that line of dialogue. The obvious thing would be think that some action on a button is the problem here, but I'm trying things and I can't find it.
Also, if I call memo at a random point of a plain dialogue, without any screen showing, it works normally and the last line before the calling only needs one click.
Again, when "memotuto" is called after that line of dialogue instead of "memo", one click is enough to advance. I have the feeling that this is important, but I don't know how.

EDIT: Okay, this is quite odd, but I believe I found the issue. As you could see by the code I posted here, every time I toggle "can" to True, i.e., everytime that I add a huge invisible blocking button to prevent player from clicking anywhere but a button, I also toggle the skip feature, by doing $ _skipping = False. I do this because, otherwise, the skip thing overrates the screen and the game might go crazy if the player hits Ctrl.
Well, one of these times is in the "aim_hi" label, the one previous to the button that triggers aim_memo. So the thing is that when I'm testing it, I always go all the way with Ctrl pressed, skipping all the dialogue until I have to click the button, when I release the Ctrl and click the button. Renpy then seems to go a bit crazy and it counts the time that has passed between _skipping was toggled and I actually released the button as if the game was somehow "busy". I checked it by toggling the _skipping on the button that triggers aim_memo, and the outcome is that the damn line of dialogue is skipped fast, as if I was pressing the Ctrl but without doing it. If I for instance toggle the skipping feature much before, I don't have any issue and the line of dialogue only needs a click.

TL;DR: I realized the "can" and "_skipping" thing is a bit of a messy system, so I want to ask you: how can I stop the game and wait for the player to interact with a screen and click a button? Like blocking the progression of a label until the player hits a button on a screen? Is that even possible? Because I asked it some days ago without success...

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Need to click twice to advance in certain dialogue

#14 Post by Alex »

There are many ways to achieve the goal in Ren'Py.
You could call the screen to make player interact with this screen only until it returns something.
You could set modal property to the screen, so game won't go farther until you hide this screen.
You can use ui.interact to wait for something to be returned from the screen.

Code: Select all

show screen my_scr
$ ui.interact()
# or
#$ res = ui.interact()
# if you need to store the value returned from the screen
https://www.renpy.org/doc/html/screen_p ... i.interact

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Need to click twice to advance in certain dialogue

#15 Post by Adrian_DVL »

Alex wrote: Wed Apr 29, 2020 3:04 pm There are many ways to achieve the goal in Ren'Py.
You could call the screen to make player interact with this screen only until it returns something.
You could set modal property to the screen, so game won't go farther until you hide this screen.
You can use ui.interact to wait for something to be returned from the screen.

Code: Select all

show screen my_scr
$ ui.interact()
# or
#$ res = ui.interact()
# if you need to store the value returned from the screen
https://www.renpy.org/doc/html/screen_p ... i.interact
Seems I have a few ways, then... Regarding the modal property, I've already tried many ways toggling the screen being modal and not modal without success. On the other hand, I've heard about ui.interact many times, but never rightly knew how to implement it properly. I'll check it out, thank you very much!

Post Reply

Who is online

Users browsing this forum: Google [Bot]