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.
Tried to use the gallery that is on the rooms page of the wiki on renpy.org, and it shows, but when it should unlock the scene related to it it doesn't unlock anything. I don't know if I'm doing it wrong, or if I'm really noob with this...
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("escena1")
g.condition("persistent.unlock_1")
g.unlock("cg/momento_divertido.png")
# This button has multiple images assocated with it. We use unlock_image
# so we don't have to call both .image and .unlock. We also apply a
# transform to the first image.
g.button("escena2")
g.unlock_image("momento")
# This button has a condition associated with it, allowing code
# to choose which images unlock.
g.button("escena3")
g.unlock_image("escena3")
g.button("escena4")
g.unlock_image("escena4")
# The last image in this button has an condition associated with it,
# so it will only unlock if the user gets both endings.
g.button("final1")
g.unlock_image("final2")
g.button("final2")
g.unlock_image("final2")
# The final two buttons contain images that show multiple pictures
# at the same time. This can be used to compose character art onto
# a background.
g.button("final3")
g.unlock_image("final3")
g.button("final4")
g.unlock_image("final4")
# The transition used when switching images.
g.transition = dissolve
# Step 3. The gallery screen we use.
screen gallery:
# Ensure this replaces the main menu.
tag menu
# The background.
add "sys/fondo.png"
# A grid of buttons.
grid 3 3:
xfill True
yfill True
# Call make_button to show a particular button.
add g.make_button("escena1", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("escena2", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("escena3", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("escena4", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("final1", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("final2", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("final3", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("final4", "sys/gallocked.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
Steamgirl wrote:Hmmm where do you set $ persistent.unlock_1 = True in your script?
Exactly after the related image is shown ingame. The thinng is that I don't know even if my game sets the variable as true or false, as it doesn't appear on the developer's menu when I try to view variables.
add g.make_button("final2", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("final3", "sys/gallocked.png", xalign=0.5, yalign=0.5)
add g.make_button("final4", "sys/gallocked.png", xalign=0.5, yalign=0.5)
if persistent.unlock_1:
text "Gallery variable is unlocked! :)" xalign 0.5 yalign 0.1
else:
text "Gallery variable is not unlocked. :(" xalign 0.5 yalign 0.1
# 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
Did the trick (I even tried using the definitions withing the game itself for the image, but putting the image route works anyway so... If it works, doun't touch it IMO