Another Noobie having CG Gallery problems (Solved!)

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
User avatar
Heiden
Regular
Posts: 140
Joined: Sat May 11, 2013 3:20 pm
Completed: Elvine, The Life Threads, Helena's Flowers, Dr. Frank's Build-A-Boyfriend, Beyond the Deep, The Bog's Heart, The Girl With the Gray Hair Awakens, The Far Rings, NB107A
Projects: The Town Pages, Kill the Prince?! [Nano 2020]
Tumblr: heidengames
itch: Heiden
Contact:

Another Noobie having CG Gallery problems (Solved!)

#1 Post by Heiden »

Hello! I'm pretty new at making visual novels and I've been struggling trying to get my CG Gallery to work. I've read through a lot of other forum posts about this same problem but I still can't seem to get it to work.

Here's what I have so far:
init python:

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

g.background = "elvineroom.png"

g.locked_button = "commonlock.png"
g.locked_background = "commonlock.png"

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

# A button that contains an image that automatically unlocks.
g.button("cglukas1")
g.image("cglukas1.png")
g.unlock("cglukas1.png")

g.button("elvinevillage")
g.unlock_image ("cgelainevillage.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("dark")
#g.unlock_image("bigbeach1")
#g.transform(slowpan)
#g.unlock_image("beach1 mary")
#g.unlock_image("beach2")
#g.unlock_image("beach3")

# This button has a condition associated with it, allowing code
# to choose which images unlock.
#g.button("end1")
#g.condition("persistent.unlock_1")
#g.image("transfer")
#g.image("moonpic")
#g.image("girlpic")
#g.image("nogirlpic")
#g.image("bad_ending")

#g.button("end2")
#g.condition("persistent.unlock_2")
#g.image("library")
#g.image("beach1 nomoon")
#g.image("bad_ending")

# 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("end3")
#g.condition("persistent.unlock_3")
#g.image("littlemary2")
#g.image("littlemary")
#g.image("good_ending")
#g.condition("persistent.unlock_3 and persistent.unlock_4")

#g.button("end4")
#g.condition("persistent.unlock_4")
#g.image("hospital1")
#g.image("hospital2")
#g.image("hospital3")
#g.image("heaven")
#g.image("white")
#g.image("good_ending")
#g.condition("persistent.unlock_3 and persistent.unlock_4")

# 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("dawn mary")
#g.unlock_image("dawn1", "mary dawn wistful")
#g.unlock_image("dawn1", "mary dawn smiling")
#g.unlock_image("dawn1", "mary dawn vhappy")

#g.button("dark mary")
#g.unlock_image("beach2", "mary dark wistful")
#g.unlock_image("beach2", "mary dark smiling")
#g.unlock_image("beach2", "mary dark vhappy")

# 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 "elvineroom.png"

# A grid of buttons.
grid 3 3:

xfill True
yfill True

# Call make_button to show a particular button.
add g.make_button("cglukas1", "lukaslock.png", xalign=0.5, yalign=0.5)
add g.make_button("elvinevillage", "lukaslock.png", xalign=0.5, yalign=0.5)
add g.make_button("cglukas1", "cglukas1.png", xalign=0.5, yalign=0.5)
add g.make_button("cglukas1", "cglukas1.png", xalign=0.5, yalign=0.5)
add g.make_button("cglukas1", "cglukas1.png", xalign=0.5, yalign=0.5)
add g.make_button("cglukas1", "cglukas1.png", xalign=0.5, yalign=0.5)
add g.make_button("cglukas1", "cglukas1.png", xalign=0.5, yalign=0.5)
add g.make_button("cglukas1", "cglukas1.png", xalign=0.5, yalign=0.5)
#add g.make_button("dawn", "gal-dawn.png", xalign=0.5, yalign=0.5)
#add g.make_button("end1", "gal-end1.png", xalign=0.5, yalign=0.5)

#add g.make_button("end2", "gal-end2.png", xalign=0.5, yalign=0.5)
#add g.make_button("end3", "gal-end3.png", xalign=0.5, yalign=0.5)
#add g.make_button("end4", "gal-end4.png", xalign=0.5, yalign=0.5)

#add g.make_button("dark mary", "gal-dark_mary.png", xalign=0.5, yalign=0.5)
#add g.make_button("dawn mary", "gal-dawn_mary.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
The only reason I have about 8 duplicates of the same button is because otherwise renpy would tell me 'Grid not completely full' and wouldn't work.

The problem is: Is that the buttons show up but they never unlock. From what I can understand, since I didn't have any g.condition statement they should show up right away. Ive played through the game to see if they were unlock after Ive seen them in game but they are still locked.

I also have another question.

In this:
g.button("cglukas1")
g.image("cglukas1.png")
g.unlock("cglukas1.png")

the g.image is the bigger image (The 800x600 image in my case) and the "lukaslock.png" in this:

add g.make_button("cglukas1", "lukaslock.png", xalign=0.5, yalign=0.5)

is the thumbnail, correct?

(I don't know if this will help but in my example the 'Cglukas1.png' is a big picture (800x600) and the Lukaslock.png and Commonlock.png are both small pictures meant to be thumbnails)

I've been struggling with this all day and I honestly don't know if I made a silly mistake or if I am using outdated code or what. This is literally the last thing preventing me from finishing my visual novel :\ Any sort of help is absolutely welcome!
Last edited by Heiden on Sat May 11, 2013 7:12 pm, edited 1 time in total.

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Another Noobie having CG Gallery problems

#2 Post by apricotorange »

Two issues. First, the unlock() method is similar to condition(); if you want to image to just always be visible in the gallery, don't use either. Second, the name you specify to g.image should be the name of the image you declared, not the filename, e.g. if you have "image bg elainevillage = 'cgelainevillage.png'", you should call "g.unlock_image('bg elainevillage')", not "g.unlock_image('cgelainevillage.png')".

User avatar
Heiden
Regular
Posts: 140
Joined: Sat May 11, 2013 3:20 pm
Completed: Elvine, The Life Threads, Helena's Flowers, Dr. Frank's Build-A-Boyfriend, Beyond the Deep, The Bog's Heart, The Girl With the Gray Hair Awakens, The Far Rings, NB107A
Projects: The Town Pages, Kill the Prince?! [Nano 2020]
Tumblr: heidengames
itch: Heiden
Contact:

Re: Another Noobie having CG Gallery problems

#3 Post by Heiden »

And now it works! Thank you so much! :D :D

User avatar
harajukulolita
Regular
Posts: 75
Joined: Mon Jul 15, 2013 11:24 am
Completed: None so far!
Projects: Currently working on... Starlight Wishes
Tumblr: loli-studio
Deviantart: harajukulolita
Contact:

Re: Another Noobie having CG Gallery problems (Solved!)

#4 Post by harajukulolita »

Can I ask a really newbie question, I'm trying out different things with the current project I'm working on. It's just a little thing to try out all different types of layouts and stuff and I'm not really sure where to put the gallery code. I've seen a it a number of times and I have it down somewhere so it wouldn't be hard for me to replace the images and everything but I just need to know where to put the code. Should it go in the screens page or in the options page or should I make a completely new .rpy file for it? Help would be greatly appreciated :D

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Another Noobie having CG Gallery problems (Solved!)

#5 Post by trooper6 »

It shouldnt' matter where you put the code. I wouldnt' put it in the options file because it isn't an option and that is messy.

You could put it in the screen file...that seems to make sense, it is a screen after all--and some people prefer fewer files rahter than more.

When I created a control screen, however, I just put it in its own file because...I liked how that looked. And I've made a separate file for all my calls as well. I'm getting the feeling that I am probably the sort of person who like more files rather than fewer files. But some folks but everything in just the script file.

It is really up to you.

As long as your indenting is all good and you have the ordering good....ti doesn't really matter as far as I know.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
harajukulolita
Regular
Posts: 75
Joined: Mon Jul 15, 2013 11:24 am
Completed: None so far!
Projects: Currently working on... Starlight Wishes
Tumblr: loli-studio
Deviantart: harajukulolita
Contact:

Re: Another Noobie having CG Gallery problems (Solved!)

#6 Post by harajukulolita »

Thanks for the help, I think I'll just create a new file for it since there will be too much stuff in the screen script but I'll try it either way. Been trying forever to get the gallery to work XD

Post Reply

Who is online

Users browsing this forum: No registered users