Gallery lock and unlock code

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
Gopi
Newbie
Posts: 7
Joined: Thu May 14, 2020 10:56 pm
Contact:

Gallery lock and unlock code

#1 Post by Gopi »

Hello everyone I'm new to renpy coding , last two days onwards iam struggling with to add lock and unlock code in gallery , the created gallery code is working fine but i don't know how to add lock and unlock the gallery when playing the player . soo i think you will help to add lock and unlocking coding . , please help me to add LOCK and UNLOCK in this code

Code: Select all

init python:
    def gallery_thumbnail(thumbnail_name):
        return im.FactorScale(thumbnail_name, 0.2)

    image_gallery = Gallery()
    image_gallery.transition = dissolve
    

    image_gallery.button("slot01")
    image_gallery.condition('True')

    image_gallery.image("1")
    image_gallery.image("6")

    image_gallery.button("slot02")
    image_gallery.condition('True')

    image_gallery.image("3")
    image_gallery.image("6")


    image_gallery.button("slot03")
    image_gallery.condition('True')

    image_gallery.image("4")
    image_gallery.image("10")

    image_gallery.button("slot04")
    image_gallery.condition('True')

    image_gallery.image("8")
    image_gallery.image("12")


    image_gallery.button("slot05")
    image_gallery.condition('True')

    image_gallery.image("14")
    image_gallery.image("6")

    image_gallery.button("slot06")
    image_gallery.condition('True')

    image_gallery.image("11")
    image_gallery.image("9")

    image_gallery.button("slot07")
    image_gallery.condition('True')

    image_gallery.image("7")
    image_gallery.image("6")

    image_gallery.button("slot08")
    image_gallery.condition('True')

    image_gallery.image("2")
    image_gallery.image("14")

    image_gallery.button("slot09")
    image_gallery.condition('True')

    image_gallery.image("2")
    image_gallery.image("7")

    image_gallery.button("slot10")
    image_gallery.condition('True')

    image_gallery.image("9")
    image_gallery.image("12")

    image_gallery.button("slot11")
    image_gallery.condition('True')

    image_gallery.image("12")
    image_gallery.image("11")

    image_gallery.button("slot12")
    image_gallery.condition('True')

    image_gallery.image("4")
    image_gallery.image("6")

    image_gallery.button("slot13")
    image_gallery.condition('True')

    image_gallery.image("10")
    image_gallery.image("6")

    image_gallery.button("slot14")
    image_gallery.condition('True')

    image_gallery.image("8")
    image_gallery.image("14")
    



    image_gallery_slots = []

    image_gallery_slots.extend(
        [
            ( "slot01", "Ch 1: Brad and Emily",         "test/6.png" ),
            ( "slot02", "Ch 1: Parker and Becky",       "test/3.png" ),
            ( "slot03", "Ch 2: Melanie\u2019s Bra",     "test/10.png" ),
            ( "slot04", "Ch 1: Brad and Emily",         "test/8.png" ),
            ( "slot05", "Ch 1: Parker and Becky",       "test/14.png" ),
            ( "slot06", "Ch 2: Melanie\u2019s Bra",     "test/11.png" ),
            ( "slot07", "Ch 1: Brad and Emily",         "test/6.png" ),
            ( "slot08", "Ch 1: Parker and Becky",       "test/2.png" ),
            ( "slot09", "Ch 2: Melanie\u2019s Bra",     "test/7.png" ),
            ( "slot10", "Ch 1: Brad and Emily",         "test/12.png" ),
            ( "slot11", "Ch 1: Parker and Becky",       "test/11.png" ),
            ( "slot12", "Ch 2: Melanie\u2019s Bra",     "test/4.png" ),
            ( "slot13", "Ch 2: Melanie\u2019s Bra",     "test/10.png" ),
            ( "slot14", "Ch 1: Brad and Emily",         "test/14.png" ),
            #( "slot02", "Ch 1: Parker and Becky",       "test/14.png" ),

        ])

    @renpy.pure
    def get_image_gallery_page_count():
        return (len(image_gallery_slots) + 5) // 6

    @renpy.pure
    def get_image_gallery_page(page):
        slots = []
        first_index = (page - 1) * 6
        for i in range(first_index, first_index + 6):
            if i < len(image_gallery_slots):
                slots.append(image_gallery_slots[i])
            else:
                slots.append((None, None, None))
        return slots

screen gallery_buttons(data):
    for (name, title, thumbnail) in data:
        if name:
            vbox:
                $ the_button = image_gallery.make_button(name, gallery_thumbnail(thumbnail))
                add the_button
                if image_gallery.buttons[name].check_unlock():
                    text title
                else:
                    text ""
        else:
            text ""

screen gallery():
    tag menu
    default page = 1
    default total_pages = get_image_gallery_page_count()


    use game_menu(_("Gallery"), scroll="viewport"):

        style_prefix "gallery"

        vbox:
            xsize 940
            ysize 500
            label "Page [page]":
                xalign 0.5
                bottom_margin 10

            grid 3 2:
                style_prefix "gallery_slot"

                xalign 0.5
                yalign 0.5

                xspacing 30
                yspacing 20

                use gallery_buttons(get_image_gallery_page(page))

            hbox:
                style_prefix "page"

                anchor (0.5, 0.0)
                pos (0.5, 1.0)

                spacing gui.page_spacing

                if page > 1:
                    textbutton _("<") action SetScreenVariable("page",
                    page - 1)
                else:
                    textbutton _("<") action NullAction()

                for i in range(1, total_pages + 1):
                    textbutton "[i]" action SetScreenVariable("page", i)

                if page < total_pages:
                    textbutton _(">") action SetScreenVariable("page",
                    page + 1)
                else:
                    textbutton _(">") action NullAction()

style gallery_slot_text:
    size 18
    xalign 0.5
    yalign 0.0

style gallery_button is button:
    hover_background "#fff"

style gallery_button_text:
    size 24
    bold True
    color "#fff"
    hover_color "#000"
    underline True

style gallery_button_current is button
style gallery_button_current_text is gallery_button_text:
    underline False
    hover_color "#fff"

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Gallery lock and unlock code

#2 Post by rayminator »

you still have to tell renpy when to unlock the image here a example

Code: Select all

"I say it shyly."
    b "I'll lick it for you."

    scene kirasex11 with dissolve
    $ persistent.unlock_11 = True

    "Kira awkwardly takes my belt off and pulls down the zipper of my pants."
    "She pulls down my underwear to find my hard cock jumping out in front of her."
hope this help you out

Gopi
Newbie
Posts: 7
Joined: Thu May 14, 2020 10:56 pm
Contact:

Re: Gallery lock and unlock code

#3 Post by Gopi »

Okay, but how to add gallery lock in my code .

Gopi
Newbie
Posts: 7
Joined: Thu May 14, 2020 10:56 pm
Contact:

Re: Gallery lock and unlock code

#4 Post by Gopi »

Please test my code and add Lock and unlock to my code .it will help me...a lot , Thanks you ....🙏

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Gallery lock and unlock code

#5 Post by rayminator »

look through this it might help you it's just that member didn't added that part of the code to tell renpy to unlock an image
viewtopic.php?f=51&t=55597

I do recommend to use the one I showed you it's a lot easier to use and to understand

you are using a different code if you made that code then you should be able to figure it out how to add the lock and unlock function to that code and if you didn't made that code where ever you got that code from maybe you be asking them how to do it

and testing you code would not work cause we don't have the images for that code

if still want to use that code

try this don't know if it will work

Code: Select all

image_locked_button = "locked.png"

    ## Edit this with your stuff and create the rest according to tutorial.
    image_button("Button_Name")
    image_unlock_image("CG_Image")

    image_button("ending1")
    image_condition("persistent.unlock_1")
    image_image("your image")

Post Reply

Who is online

Users browsing this forum: Google [Bot]