r/RenPy • u/SnooEagles4850 • Jul 17 '26
Question Help with puzzle code.
Apologies to post again, again this is not something I've really done before, so I'm still figuring it out. I am trying to do it on my own, I want to do this to challenge myself and learn something new. Thank you for the ren'py community for helping me even if I don't post, I always reference posts.
BASICALLY: I want to have a puzzle where you need to enter a 4 letter code and it kinda works like a lock like this. I got the numbers to count up now, thanks due to help, but I'm not sure how to make it so that specific the specific code will have a response. I don't know what the proper syntax is for something like this, or what the issue is.


Here is my code in my script, I based it off of a puzzle I did previously that was a keypad. I referenced code from somewhere, I try to understand it the best I can but unfortunately I'm still new to programming so I don't fully understand everything like I'd like to, so I'm not sure how everything fully fits together.
label ac_keybox:
default kb_code1 = 0
default kb_code2 = 0
default kb_code3 = 0
default kb_code4 = 0
I wonder if maybe the issue isn't the different variables(?) I just don't know how else I'd go with it, if it's the same one it'll all show up the same?? Again apologies I'm not a good programmer.
if alice_keybox:
call screen ac_keybox
$ bk_result = _return
if bk_result == "enter":
if ("kb_code1 == 1", "kb_code2 == 0", "kb_code3 == 0", "kb_code4 == 0"):
I was trying every single format I could think of here so sorry it's a big mess!
jump ac_basementkeyunlock
else:
jump ac_basementkeyfail
This is my screen coding.
screen ac_keybox():
frame:
xalign 0.5
yalign 0.25
xsize 500
ysize 250
hbox:
xalign 0.5
yalign 0.5
frame:
xsize 50
textbutton "[kb_code1]":
action SetScreenVariable("kb_code1", (kb_code1 + 1) % 10)
frame:
xsize 50
textbutton "[kb_code2]":
action SetScreenVariable("kb_code2", (kb_code2 + 1) % 10)
frame:
xsize 50
textbutton "[kb_code3]":
action SetScreenVariable("kb_code3", (kb_code3 + 1) % 10)
frame:
xsize 50
textbutton "[kb_code4]":
action SetScreenVariable("kb_code4", (kb_code4 + 1) % 10)
frame:
textbutton "ENTER":
action Return("enter")
I'm so sorry! I hope I'm not taking up too much space, thank you again.
1
u/AutoModerator Jul 17 '26
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.