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.
-
erintesden
- Newbie
- Posts: 2
- Joined: Sat May 30, 2020 4:37 pm
-
Contact:
#1
Post
by erintesden » Sun May 31, 2020 7:00 pm
Im trying to do this scene where a character tries to open a safe with an integrated IA, that accepts both numbers and letters for its password.
And its my intention to make so that you have the correct password that opens the safe, some specific wrong passwords that result in special dialogues, and a generic wrong password dialogue (else).
I found a similar old to what I wanted and tried to do it but it didnt worked. This is what I did:
Code: Select all
label start:
"Okay, lets do it!"
jump safe
label safe:
menu:
"Try again.":
jump code
"No":
return
label code:
$ pass1 = "3401"
$ pass2 = ("shit" "fuck")
$ pass3 = ("1234", "123456", "0000", "000000", "654321")
$ pass4 = "IA´S NAME"
$ code = renpy.input ("Input your answer.")
if code == pass1:
"Correct Answer!"
return
if code == pass2:
"Wrong Answer. Try again!"
jump safe
if code == pass3:
"Language! Try again!"
jump safe
if code == pass4:
"Wrong Answer! But Im flattered! Try again!"
jump safe
else:
"Wrong Answer."
jump safe
Thats it. I have tried to change some stuff around but the result is the same, the only option that works like it should is the "pass4", any of the other passwords always get me the dialogue of "else" variable. Not sure why
-
rayminator
- Miko-Class Veteran
- Posts: 754
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
-
Contact:
#2
Post
by rayminator » Sun May 31, 2020 7:37 pm
some of your code is wrong
if code1
if code2
if code3
else ---- this else will go for the last if and ignored the rest
Code: Select all
if code == pass1:
"Correct Answer!"
return
elif code == pass2:
"Wrong Answer. Try again!"
jump safe
elif code == pass3:
"Language! Try again!"
jump safe
elif code == pass4:
"Wrong Answer! But Im flattered! Try again!"
jump safe
else:
"Wrong Answer."
jump safe
here is another password if you want to look at it
viewtopic.php?f=51&t=52536
-
SONTSE
- Regular
- Posts: 95
- Joined: Sun Nov 24, 2013 10:49 pm
- Completed: 8 VN's so far
-
Contact:
#3
Post
by SONTSE » Sun May 31, 2020 7:42 pm
if your answer is list of possible variants, you check it with 'in' instead of '=='
Code: Select all
if code in pass2:
"Wrong Answer. Try again!"
jump safe
if code in pass3:
"Language! Try again!"
jump safe
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)
-
rames44
- Veteran
- Posts: 232
- Joined: Sun May 29, 2016 4:38 pm
-
Contact:
#4
Post
by rames44 » Mon Jun 08, 2020 12:35 pm
Also, note that the use of parentheses creates a Python “tuple,” which is probably not what you want. You probably want a list (square brackets) or a set (curly braces).