Sorry for the vague title, not sure how to phrase it.
I already know which part breaks the code, but I don't know how to fix it... So lemme just show you and explain it.
label user123:
$ user1_input = renpy.input(prompt = "Input code. To leave, enter '0'", allow="1234567890")
$ user1_input = user1_input.lower().strip()
if user1_input == "": #This will happen if there's no input.
system "You need to actually write something..."
jump user123
if user1_input in ('0'):
jump user1
if user1_input == ('123') and x == False:
system "stuff is said"
$ x = True
elif user1_input == ('432'):
system "blergh"
elif user1_input == ('123','432'): # if you remove the '432' the code will work.
$ xyz = renpy.random.randint(1,3)
if xyz == 1:
system "more stuff is said"
if xyz == 2:
system "more stuff more stuff"
if xyz == 3:
system "this is more stuff being said"
jump user123
any help will be appreciated!
[Solved] Input menu, go to a new result?
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.
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.
[Solved] Input menu, go to a new result?
Last edited by Rekoija on Sun May 24, 2020 3:30 pm, edited 1 time in total.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: Input menu, go to a new result?
are you trying to phrase in the elif something like this? `elif user1_input is equal to 123 or user1_input is equal to 432`? if that's the case you should use `or` to separate multiple conditions like that or create a tuple / list of choices and use `in` operator.
Code: Select all
default user1_input = "" # always default variables that you plan to change in different parts of your code. Nonetheless, always default your variables to be sure...
default x = False
default xyz = 0
label user123:
$ user1_input = renpy.input(prompt = "Input code. To leave, enter '0'", allow="1234567890")
$ user1_input = user1_input.lower().strip()
if not user1_input: # the previous one is valid, but this one is much better to test if a string is empty.
system "You need to actually write something..."
jump user123
if user1_input == '0': # changed from user1_input in ('0')
jump user1
if user1_input == '123' and not x: # not x is equivalent to x == False
system "stuff is said"
$ x = True
elif user1_input == '432':
system "blergh"
elif user1_input in ('123','432'): # checks whether the input is within the tuples of codes 123 and 432, if true execute below
$ xyz = renpy.random.randint(1,3)
if xyz == 1:
system "more stuff is said"
elif xyz == 2:
system "more stuff more stuff"
elif xyz == 3:
system "this is more stuff being said"
jump user123
Re: Input menu, go to a new result?
The above code from hell_oh_world is correct, the expalantion is:
What you are asking this way if the input is TOTALLY EQUAL a tuple so made: ('123',432')
And it throw an error as your user_input1 is a single string, something like '123' or '571'.
To check if a string is legit on a numer of possible strings, you must check if that string is in the tuple.
This one, for example, check if the string is present in a list of 3 possible combinations.
==============================
Conditionals Explained
(Small extra tutorial!)
The truth check ('if... something') work mostly this way.
IF {whatever follow} RETURN TRUE:
so you can check things based if they return true or false.
The conditional return False, as 'name' is not equal 'Gas'. so the following block is not executed.
If 4/2 == 3: # is true that 4 divided by 2 is equal 3?
this will never pass the check, as the reply is False.
For booleans, a value that is False return false and a value that is True return true.
You don't need to check if a boolean is 'True' or 'False', python use the boolean flag to determine it.
if not check:
this one for example verifiy if the variable 'check' is not True, so if it's False
You can also quote functions directly and check if they return True.
if my_function(value =100):
In that case the condition is met if the function, after computing, return True.
And that's all about conditionals.
Code: Select all
elif user1_input == ('123','432'): # if you remove the '432' the code will work.
And it throw an error as your user_input1 is a single string, something like '123' or '571'.
To check if a string is legit on a numer of possible strings, you must check if that string is in the tuple.
This one, for example, check if the string is present in a list of 3 possible combinations.
Code: Select all
elif user1_input in ('123','432', 571'):
Conditionals Explained
(Small extra tutorial!)
The truth check ('if... something') work mostly this way.
IF {whatever follow} RETURN TRUE:
so you can check things based if they return true or false.
Code: Select all
default name = "Greg"
if name == "Gas":
If 4/2 == 3: # is true that 4 divided by 2 is equal 3?
this will never pass the check, as the reply is False.
For booleans, a value that is False return false and a value that is True return true.
Code: Select all
$ default check = True
if check:
if not check:
this one for example verifiy if the variable 'check' is not True, so if it's False
You can also quote functions directly and check if they return True.
if my_function(value =100):
In that case the condition is met if the function, after computing, return True.
And that's all about conditionals.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
Re: Input menu, go to a new result?
hell, you're a life saver for reals, thank you so much, I would've never figured this out on my own. MVP!
i really appreciate the help!
it took me a bit to understand, and i had to line it up next to my own code and try to figure out what you'd changed, but when i finally realized, wow. thank you thank you thank you xD
i really appreciate the help!
it took me a bit to understand, and i had to line it up next to my own code and try to figure out what you'd changed, but when i finally realized, wow. thank you thank you thank you xD
Who is online
Users browsing this forum: No registered users