Page 1 of 1

variables working with vpgrids??

Posted: Mon Oct 30, 2023 5:20 pm
by pinkcateye
i am trying to make an endings screen for my renpy game. i want the endings screen to be like the lily's day off endings screen where you can click on an ending you got and it will jump to that ending so you can replay it. i am currently trying to get this to work with a vpgrid.
any help is appreciated! :D

Code: Select all

default persistent.endings = ["Ending 1", "Ending 2"]

## dont disable this, it will cause glitches
define config.allow_underfull_grids = True

screen endings():

    tag menu

    vpgrid:
        
        xalign 0.5
        yalign 0.5

        cols 1
        spacing 10

        mousewheel True

        for t in persistent.endings:
            # here is supposed to be code that makes a new button for every item in the persistent.endings list

    textbutton _("Return"):
        yalign 1.0
        xalign 0.0

        action Return()

Re: variables working with vpgrids??

Posted: Mon Oct 30, 2023 5:44 pm
by PyTom
So. that's not really how you wanted to do this. I'll say that you probably don't want a vpgrid unless you have so many endings that it won't fit on one screen - if you have only a few, a vbox is fine.

You also probably want a different structure to indicate which endings are unlocked.

Code: Select all

define endings = [
     ( "ending_1", _("A New Day")),
     ( "ending_2", _("The End of All Things")),
     ]

screen endings():
     tag menu
     
     use game_menu(_("Endings")):
           vbox:
                 for flag, label in all_endings:
                       if getattr(persistent, flag):
                             text "[label]"
                       else:
                             text _("(Ending Locked)")
To unlock an ending, do:

Code: Select all

    $ persistent.ending_1 = True


Note that I'm just typing this into the board, and I haven't tested it.

Re: variables working with vpgrids??

Posted: Mon Oct 30, 2023 5:56 pm
by pinkcateye
i have a lot of endings, and i think a vpgrid would be best personally, but thank you very much for helping!

Do you think this will work? :)

Code: Select all

screen endings():

    tag menu

    vpgrid:
        
        xalign 0.5
        yalign 0.5


        cols 1
        spacing 10

        mousewheel True

        for flag, label in all_endings:
                    if getattr(persistent, flag):
                            text "[label]"
                    else:
                            text _("(Ending Locked)")

    textbutton _("Return"):
        yalign 1.0
        xalign 0.0

        action Return()


Re: variables working with vpgrids??

Posted: Mon Oct 30, 2023 6:02 pm
by PyTom
Sure. In that case, you can replace:

Code: Select all

           vbox:
with:

Code: Select all

         vpgrid:
        
            xalign 0.5
            yalign 0.5

            cols 1
            spacing 10

            mousewheel True
(Indented properly.)

Re: variables working with vpgrids??

Posted: Mon Oct 30, 2023 6:06 pm
by pinkcateye
oh no :0

i tested it and...


Image

Re: variables working with vpgrids??

Posted: Mon Oct 30, 2023 6:10 pm
by pinkcateye
wait i got it to work! tysm pytom!! this helped alot!!

Code: Select all

# i replaced "all_endings" with "endings"
for flag, label in endings:
                    if getattr(persistent, flag):
                            textbutton "[label]" action Call(label)
                    else:
                            textbutton _("(Ending Locked)")