Page 1 of 1

HELP error in coding a journal screen

Posted: Wed Oct 19, 2022 9:36 pm
by yasminuscula
so, I want the player to be able to acess a simple journal with important information to the game progression, right?
I managed to successfully add a button on the navigation menu:

Image
I just added a button that calls a screen to the nav buttons:

Code: Select all

if quick_menu:

        hbox:
            style_prefix "quick"

            xalign 0.5
            yalign 1.0

            textbutton _("Back") action Rollback()
            textbutton _("History") action ShowMenu('history')
            textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
            textbutton _("Auto") action Preference("auto-forward", "toggle")
            textbutton _("Save") action ShowMenu('save')
            textbutton _("Q.Save") action QuickSave()
            textbutton _("Q.Load") action QuickLoad()
            textbutton _("Prefs") action ShowMenu('preferences')
            textbutton _("journal") action Show('nav_screen') ##right here
            
            
and the code for the screen looks like this:

Code: Select all

screen nav_screen():
    add "journal.png"
    modal True
    textbutton _("voltar"):
        style "return_button"

        action Return()
when I click, it works, and I added a "return" button on the bottom left (that's written as 'voltar' because is in my native language) as seen here:
Image

but then it when I click on return the image of the journal doesn't disappear, the game text keeps going but the image is still there:
Image
i tried to hide it but is never valid, how do I do this?

Re: HELP error in coding a journal screen

Posted: Wed Oct 19, 2022 10:13 pm
by _ticlock_
Use modal True and Hide instead of Return(). A modal screen prevents the user from interacting with displayables below it. Return is used to return from call screen, you need to use Hide when you use show screen or Show action.

Code: Select all

screen nav_screen():
    modal True
    add "journal.png"
    modal True
    textbutton _("voltar"):
        style "return_button"

        action Hide("nav_screen")

Re: HELP error in coding a journal screen

Posted: Thu Oct 20, 2022 9:56 am
by yasminuscula
_ticlock_ wrote:
Wed Oct 19, 2022 10:13 pm
Use modal True and Hide instead of Return(). A modal screen prevents the user from interacting with displayables below it. Return is used to return from call screen, you need to use Hide when you use show screen or Show action.

Code: Select all

screen nav_screen():
    modal True
    add "journal.png"
    modal True
    textbutton _("voltar"):
        style "return_button"

        action Hide("nav_screen")
thank youu, it worked (something so simple haha)