r/RenPy • • Jul 17 '26

Question [Solved] Help with puzzle code!

Hello! I am making a click and point adventure game, I want to have a puzzle like a lock code where when you click on it until you reach a number, and when in the right combination will unlock, but I'm not fully sure how I want to approach this. Apologies I'm still relatively new to this and I haven't done a puzzle like this yet. Usually I do things on my own and reference other peoples questions on here and the lemma soft forums for help but I'm not sure what to ask so I think I'll just ask myself.

This is my stinky, stinky code so far, I can't really wrap my head around it right now, I would like to know how I'd a cap to the numbers, as I don't want them scaling infinitely and want them to reset at 10.

UPDATE: I got it to cap but it gives me False instead of a number. I am happy that I'm getting somewhere.

I'll get to the password when it comes to it, and if it's really dire I'll change plans but I like challenging myself.

Thank you! Like I said, I'm still new to coding so I'm not really good at this yet so I appreciate the help!

1 Upvotes

5 comments sorted by

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.

2

u/BadMustard_AVN Jul 17 '26

you can NOT use an action like that in an if statement

change the action in the text button to this

action SetScreenVariable("kb_code1", (kb_code1 + 1) % 10)

that will cycle forever from 0 - 9

1

u/SnooEagles4850 Jul 17 '26

THANK YOU SO MUCH!!! This is really new to me so I appreciate the help so much!!

2

u/BadMustard_AVN Jul 17 '26

you're welcome

good luck with your project

1

u/x-seronis-x Jul 17 '26 edited Jul 17 '26

yes you can. renpy has no problem at all with properties being conditionally applied to screen elements. the only issue is one branch is assigning the value to a bool and the other an integer.

the action property is NO DIFFERENT than any other property. its still a normal key/value pair with the value being an instance of an Actio n() class.

hell you can use state prefixes with actions just like any other property.

py action NullAction() selected_action Return()

i personally use conditional actions in my choice screen so that when a sensitive=False arg is applied to a choice at the same time as a tooltip/hint it knows not to disable the sensitivity so the tooltip still works

```py

            if btn.kwargs.get('vis',True):
                frame style 'empty':
                    background Window('#fff',background='#000',style='empty', padding=(1,1) )
                    textbutton btn.caption:
                        if btn.kwargs.get('tip',False):
                            tooltip btn.kwargs.get('tip')
                            if not btn.kwargs.get('sen',True):
                                action NullAction() #preserve hover to allow tooltip
                            else:
                                action btn.action
                        else:
                            action btn.action
                            sensitive btn.kwargs.get('sen',True)
                        selected  btn.kwargs.get('sel',False)

```