Page 1 of 1

Help with unlocking gallery image from script

Posted: Tue Jun 01, 2021 10:41 pm
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?

Re: Help with unlocking gallery image from script

Posted: Tue Jun 01, 2021 11:20 pm
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

Re: Help with unlocking gallery image from script

Posted: Wed Jun 02, 2021 12:18 am
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.

Re: Help with unlocking gallery image from script

Posted: Wed Jun 02, 2021 2:00 am
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

Re: Help with unlocking gallery image from script

Posted: Wed Jun 02, 2021 7:41 am
by mavyxdawn
If you're still having troubles making it work, you can download this template:
https://zeillearnings.itch.io/image-gallery-template