How should I lock/unlock images in this case (gallery)?

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
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

How should I lock/unlock images in this case (gallery)?

#1 Post by Nanahs »

I created a label that is a gallery.

I'm using this:

Code: Select all

label gallery1:       
        
    scene bluescenary
    
screen images1:
    vbox:
        pos (100, 300)
        spacing 15
        imagebutton idle im.FactorScale('image1.png', 1.0) action Jump("image1")
        imagebutton idle im.FactorScale('image2.png', 1.0) action Jump("image2")
        imagebutton idle im.FactorScale('image3.png', 1.0) action Jump("image3")
        imagebutton idle im.FactorScale('image4.png', 1.0) action Jump("image4")


label image1:
    scene image1
    $ renpy.pause()
    jump label gallery1
The images are displayed like this:

Image

It's all ok. But I'm using a Messenger system (viewtopic.php?f=51&t=50153).
And in the chat you can "receive" images.

I wanted the images you receive in the Messenger to only be available in the gallery after you play the label you will receive them.

They would appear "black" in the gallery. Like this:

Image

I was thinking that in the label I use the messenger, after you "receive" the messege, I should use something like:

Code: Select all

$ unlock_image("image4")
But I'm not sure it this code exists, or if it's done this way :?:

Not all images will be locked. Some will start the game available already.

Also, how do I "tell" the game that this image:

Code: Select all

        imagebutton idle im.FactorScale('image4.png', 1.0) action Jump("image4")
Should only be available to open as the others:

Code: Select all

label image4:
    scene image4
    $ renpy.pause()
    jump label gallery1
After I use something like:

Code: Select all

$ unlock_image("image4")
:?: :?: :?: :oops: :lol:

Sorry if it's confusing :oops: :lol:

Thanks :)

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How should I lock/unlock images in this case (gallery)?

#2 Post by Per K Grok »

Nanahs wrote: Fri Feb 01, 2019 9:29 am
----
I wanted the images you receive in the Messenger to only be available in the gallery after you play the label you will receive them.

They would appear "black" in the gallery. Like this:

Image

I was thinking that in the label I use the messenger, after you "receive" the messege, I should use something like:

Code: Select all

$ unlock_image("image4")
-----
You can do this in this way.

You have a variable for each image that starts out as locked and set those variables to False as default.

default img4unlocked= False

In the screen you have if-statements for showing the button for the image (if unlocked) or an image showing that this image is locked

Code: Select all

if img4unlocked== True:
    imagebutton idle im.FactorScale('image4.png', 1.0) action Jump("image4")
else:
    add 'lockedImage'
At the event that unlocks the image you do
$ img4unlocked= True

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: How should I lock/unlock images in this case (gallery)?

#3 Post by Nanahs »

Per K Grok wrote: Sat Feb 02, 2019 8:09 am
Nanahs wrote: Fri Feb 01, 2019 9:29 am
----
I wanted the images you receive in the Messenger to only be available in the gallery after you play the label you will receive them.

They would appear "black" in the gallery. Like this:

Image

I was thinking that in the label I use the messenger, after you "receive" the messege, I should use something like:

Code: Select all

$ unlock_image("image4")
-----
You can do this in this way.

You have a variable for each image that starts out as locked and set those variables to False as default.

default img4unlocked= False

In the screen you have if-statements for showing the button for the image (if unlocked) or an image showing that this image is locked

Code: Select all

if img4unlocked== True:
    imagebutton idle im.FactorScale('image4.png', 1.0) action Jump("image4")
else:
    add 'lockedImage'
At the event that unlocks the image you do
$ img4unlocked= True
Thank you so much! I'll try doing it :)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot