Lock Combination Puzzle

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.
Message
Author
Fatimah
Regular
Posts: 94
Joined: Tue Mar 01, 2016 2:53 pm
Contact:

Re: Lock Combination Puzzle

#16 Post by Fatimah »

philat wrote:Well, honestly can't help you, because it's working fine for me. I guess you can try using image lock1 = DynamicImage("lock_[d1].png") to force it to DynamicImage, but it really shouldn't be necessary (and is working for me with just "lock_[d1].png" on 6.99.11).
Thank you for your help.
I finally got it to work. Turns out I had to define the images just like this "lock_[d]"

User avatar
lil steffi
Newbie
Posts: 8
Joined: Sun Oct 07, 2018 1:12 pm
Contact:

Re: Lock Combination Puzzle

#17 Post by lil steffi »

this is a dead link to the image, but I really would like to try implementing something like this in my game. Do you happen to have the image that was originally posted so I can see how this works?
philat wrote: Tue Nov 22, 2016 3:50 am I'm assuming by combination you mean something like this? https://upload.wikimedia.org/wikipedia/ ... n_lock.jpg

I can't quite tell what you're trying to do from the code snippets you posted, so the following assumes a 4 digit lock, with 10 possible answers for each digit (0~9), and that you have images named lock_1.png, lock_2.png, etc. in the appropriate folder. Haven't tested the dynamic images, but they should work, or I've made a dumb syntax mistake somewhere -- the concept should be fine.

Code: Select all

default d1=0
default d2=0
default d3=0
default d4=0

image lock1 = "lock_[d1].png"
image lock2 = "lock_[d2].png"
image lock3 = "lock_[d3].png"
image lock4 = "lock_[d4].png"

screen lockpuzzle():
    vbox:
        hbox:
            add "lock1"
            add "lock2"
            add "lock3"
            add "lock4"

        textbutton "1 ↑" action If(d1<9, SetVariable("d1", d1+1), SetVariable("d1", 0))
        textbutton "1 ↓" action If(d1>0, SetVariable("d1", d1-1), SetVariable("d1", 9))
        # duplicate the buttons for all four digits
        # use the condition below to check for the right answer
        textbutton "Open" action If(d1==1 and d2==2 and d3==3 and d4==4, Jump("yes"), Jump("no"))

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Lock Combination Puzzle

#18 Post by philat »

I have no idea, I just pulled it off google. In any case, the screen is simple enough. Also look here for a similar example: viewtopic.php?f=51&t=51868

Post Reply

Who is online

Users browsing this forum: Kocker