GC Gallery problems...

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
desulishor
Regular
Posts: 146
Joined: Wed Aug 11, 2010 1:35 pm
Completed: Project Dualis, Of Valkyries and Life
Projects: Project Scribble [on hiatus] Project Aivisu (WIP) Seven Seasons (WIP)
Location: Finland
Contact:

GC Gallery problems...

#1 Post by desulishor »

So, I was trying to make a GC gallery, but I'm having a bit of trouble with buttons and unlockable conditions. Below is a quote of the code I'm using, but at the moment, none of the unlockable buttons work.

I tried using unlock conditions like this:

Code: Select all

$ persistent_unlock = True
$ persistent_unlock = False
but no luck. Do these values actually retain true status after you return to main menu or not? and how should one code their unlock conditions then?

Code: Select all

init python:

    # Step 1. Create the gallery object.
    g = Gallery()

    # Step 2. Add buttons and images to the gallery.

    # A button that contains an image that automatically unlocks.
    g.button("bg logo")
    g.unlock_image("bg logo")
    
    # This button has a condition associated with it, allowing code
    # to choose which images unlock.
    g.button("bg ye")
    g.condition("persistent.unlock_1")
    g.image ("bg reader")
    g.image ("bg yukihosp")
    g.image("bg yukidream")
    g.image("bg hug")
    g.image("bg hospend")
    g.image("bg towerend")
    
    g.button("bg ue")
    g.condition("persistent.unlock_2")
    g.image ("bg reader")
    g.image ("bg yukihosp")
    g.image ("bg whitekiss")
    g.image("bg hospend")
    g.image ("bg karaokepic")
    
    g.button ("bg oe")
    g.condition ("persistent.unlock_3")
    g.image ("bg reader")
    g.image ("bg yukihosp")
    g.image ("bg  benchkiss")
    g.image ("bg yumidream")

    # The transition used when switching images.
    g.transition = fade

# Step 3. The gallery screen we use.
screen gallery:

    # Ensure this replaces the main menu.
    tag menu

    # The background.
    add "gallery"

    # A grid of buttons.
    grid 3 3:

        xfill True
        yfill True

        # Call make_button to show a particular button.
        add g.make_button("bg logo", "icon.png", xalign=0.5, yalign=0.5)
        add g.make_button("bg oe", "oe.png", xalign=0.5, yalign=0.5)
        add g.make_button("bg ue", "ue.png", xalign=0.5, yalign=0.5)
        
        add g.make_button("bg ye", "ye.png", xalign=0.5, yalign=0.5)
        add g.make_button("bg logo", "icon.png", xalign=0.5, yalign=0.5)
        add g.make_button("bg logo", "icon.png", xalign=0.5, yalign=0.5)
        
        add g.make_button("bg logo", "icon.png", xalign=0.5, yalign=0.5)
        add g.make_button("bg logo", "icon.png", xalign=0.5, yalign=0.5)
        
        # The screen is responsible for returning to the main menu. It could also
        # navigate to other gallery screens.
        textbutton "Return" action Return() xalign 0.5 yalign 0.5

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

Re: GC Gallery problems...

#2 Post by Alex »

The problem might be if you set the values of persistent variables in init block - in that case the values will be set everytime you run the game. The proper way would be

Code: Select all

init:
    if not persistent.unlock_1:    # if there is no value for this var at all
        $ persistent.unlock_1 = False
So later in the game you could change the value of persistent.unlock_1 and it won't change the next time you start the game.
Last edited by Alex on Fri Mar 08, 2013 5:21 pm, edited 1 time in total.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: GC Gallery problems...

#3 Post by xavimat »

desulishor wrote:

Code: Select all

$ persistent_unlock = True
$ persistent_unlock = False
Also, you need to use the variables:

Code: Select all

persistent.something
with a period, and not

Code: Select all

persistent_something
Last edited by xavimat on Sun Mar 10, 2013 6:20 am, edited 1 time in total.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

desulishor
Regular
Posts: 146
Joined: Wed Aug 11, 2010 1:35 pm
Completed: Project Dualis, Of Valkyries and Life
Projects: Project Scribble [on hiatus] Project Aivisu (WIP) Seven Seasons (WIP)
Location: Finland
Contact:

Re: GC Gallery problems...

#4 Post by desulishor »

Thanks again, seems to be working now.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Ocelot, Princesky