variables working with vpgrids??

Forum organization and occasional community-building.
Forum rules
Questions about Ren'Py should go in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
pinkcateye
Newbie
Posts: 8
Joined: Mon Oct 30, 2023 4:58 pm

variables working with vpgrids??

#1 Post 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()

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: variables working with vpgrids??

#2 Post 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.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
pinkcateye
Newbie
Posts: 8
Joined: Mon Oct 30, 2023 4:58 pm

Re: variables working with vpgrids??

#3 Post 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()

Last edited by pinkcateye on Mon Oct 30, 2023 6:03 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: variables working with vpgrids??

#4 Post 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.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
pinkcateye
Newbie
Posts: 8
Joined: Mon Oct 30, 2023 4:58 pm

Re: variables working with vpgrids??

#5 Post by pinkcateye »

oh no :0

i tested it and...


Image
Attachments
Screenshot 2023-10-30 180529.png
(148.48 KiB) Not downloaded yet

User avatar
pinkcateye
Newbie
Posts: 8
Joined: Mon Oct 30, 2023 4:58 pm

Re: variables working with vpgrids??

#6 Post 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)")

Post Reply

Who is online

Users browsing this forum: Amazon [Bot]