Page 1 of 1

Closing a custom screen chooses a menu item.

Posted: Thu Jan 04, 2024 6:33 am
by Swinwappy
Hey guys, I have a phone UI in my game. Whenever I open this UI in a zone with a menu, the last item in the menu is selected.

Does anyone have any idea why this might be happening?

Here's a video of the bug in action.
https://youtu.be/hz1tgVsYOB0

This is the MC's bedroom, where menus are present.

Code: Select all

 label bedroom:
        call screensrefresh

        if clock.time_of_day in ["10PM", "11PM", "12AM", "1AM", "2AM", "3AM"]:
            scene bedroomnighttime with fade
        else:
            scene bedroomday with fade
        menu:
            "Work out":
                "You work out for an hour."
                $ clock.advance(1)
                jump bedroom

            "Study":
                "You study for an hour."
                $ clock.advance(1)
                jump bedroom

            "nada":
                "de nada" #exiting the hud will always choose the last menu item
        jump bedroom
    return
This is the button to close the phone:

Code: Select all

screen hud():
    hbox xalign 0.5 yalign 0.945:
        #phone home button
        imagebutton:
            idle "homebutton.png"
            hover "homebuttonhover.png"
            action Call ("phoneexit")
This is the "function" that closes the phone screen.

Code: Select all

label phoneexit:
    hide screen hud
    show screen hud
    hide screen phonebuttons
    hide screen phoneprofiles
    hide screen contactnames
    hide phonehome
    hide phoneprofiles
    hide phonemain
    hide screen phoneprofilescreen
    hide screen contactnames
    hide phonemap
    hide screen map
    pause .1
    return

Re: Closing a custom screen chooses a menu item.

Posted: Thu Jan 04, 2024 6:46 am
by Swinwappy
Ok, I think it has something to do with the returning. When I replace "Return" with "Jump Bedroom" on the function that closes the phone screen, it seems to work fine.

Re: Closing a custom screen chooses a menu item.

Posted: Thu Jan 04, 2024 11:04 am
by Ocelot
Calling a label terminates current statement (in your case a menu statement) by default. I am pretty surprised it actually chose anything instead of skipping menu entirely. Baiscally, don't call stuff if you are not done with stuff on the screen.

Re: Closing a custom screen chooses a menu item.

Posted: Thu Jan 04, 2024 10:18 pm
by Swinwappy
Ocelot wrote: Thu Jan 04, 2024 11:04 am Calling a label terminates current statement (in your case a menu statement) by default. I am pretty surprised it actually chose anything instead of skipping menu entirely. Baiscally, don't call stuff if you are not done with stuff on the screen.
Thanks for the response. Do you have any idea how I might close this menu when the player opens there phone? Is there a better way of doing this?

Cheers.

Re: Closing a custom screen chooses a menu item.

Posted: Fri Jan 05, 2024 4:01 am
by Ocelot
Yes, just hide the screen and do not call any labels if you want for it to work properly in menus. Alternatively, disable ability to use phone in menus.
To handle ungodly amount of hiding you do, either make them be used in some kind of root screen, or hide them in Python function you can invoke.
You can also try Call ("phoneexit", from_current=True) but this can lead to problems in other places.