Help with unlocking gallery image from script

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
ShadoStalk3r
Newbie
Posts: 9
Joined: Mon Oct 29, 2018 6:17 am
Contact:

Help with unlocking gallery image from script

#1 Post by ShadoStalk3r »

Hi all,

I have a gallery built in that typically unlocks an image as it is seen in the game. But I would rather use a code in the script file itself that unlocks an image of my choosing.
I've tried in my script file:

Code: Select all

$ g.unlock_image("ImageIWantUnlocked")
And get nothing at all.

And also:

Code: Select all

$ Gallery.unlock_image("ImageIWantUnlocked")
But I get this:

Code: Select all

While running game code:
  File "game/script.rpy", line 82, in script
    $ Gallery.unlock_image("ImageIWantUnlocked")
  File "game/script.rpy", line 82, in <module>
    $ Gallery.unlock_image("ImageIWantUnlocked")
TypeError: unbound method unlock_image() must be called with Gallery instance as first argument (got unicode instance instead)
But it won't unlock anything in my gallery.

How do I do this?

User avatar
mavyxdawn
Regular
Posts: 72
Joined: Sun Dec 20, 2015 6:18 pm
Github: mavyxdawn
itch: zeillearnings
Discord: _zeil
Contact:

Re: Help with unlocking gallery image from script

#2 Post by mavyxdawn »

If you have this in your Image gallery code:

Code: Select all

    g.button("end1")
    g.condition("persistent.end1")
    g.image("end1.jpg")
    
Your script.rpy should use

Code: Select all

$ persistent.end1 = True
Reference: viewtopic.php?f=51&t=46976#p471546
YouTube: Zeil Learnings
itch.io: Zeil Learnings

Image

ShadoStalk3r
Newbie
Posts: 9
Joined: Mon Oct 29, 2018 6:17 am
Contact:

Re: Help with unlocking gallery image from script

#3 Post by ShadoStalk3r »

mavyxdawn wrote: Tue Jun 01, 2021 11:20 pm If you have this in your Image gallery code:

Code: Select all

    g.button("end1")
    g.condition("persistent.end1")
    g.image("end1.jpg")
    
Your script.rpy should use

Code: Select all

$ persistent.end1 = True
Reference: viewtopic.php?f=51&t=46976#p471546
Unfortunately, there's no g.condition in my Gallery script. I added it inbetween g.button and g.unlock_image but it doesn't do anything.

User avatar
mavyxdawn
Regular
Posts: 72
Joined: Sun Dec 20, 2015 6:18 pm
Github: mavyxdawn
itch: zeillearnings
Discord: _zeil
Contact:

Re: Help with unlocking gallery image from script

#4 Post by mavyxdawn »

Oh. You'll need the g.condition to lock your image.

Then in your grid:
add g.make_button("end1","end1small.jpg", locked = "lock.png")

I'll upload a sample code later in my itch.io
YouTube: Zeil Learnings
itch.io: Zeil Learnings

Image

User avatar
mavyxdawn
Regular
Posts: 72
Joined: Sun Dec 20, 2015 6:18 pm
Github: mavyxdawn
itch: zeillearnings
Discord: _zeil
Contact:

Re: Help with unlocking gallery image from script

#5 Post by mavyxdawn »

If you're still having troubles making it work, you can download this template:
https://zeillearnings.itch.io/image-gallery-template
YouTube: Zeil Learnings
itch.io: Zeil Learnings

Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]