I have a new problem with an input...

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.
Post Reply
Message
Author
Himekuri
Newbie
Posts: 8
Joined: Wed Oct 16, 2013 1:36 pm
Contact:

I have a new problem with an input...

#1 Post by Himekuri »

Hi I'm trying to write a code that responds to the player writing certain words
so far I have

Code: Select all

$ name = renpy.input("How are you today master?", length=20) or "Noname"    


if ((name != "Good") and (name != "Ok") and (name != "Fine") and (name != "Great") and (name != "k")):        
      jump bad
hide chihiro happy
show chihiro glad
c "That's good to hear!"      # %(name)s is old. you can use brackets to do it.

label bad:
c "Aw, well I hope things get better soon."
However if I write in "Good" it still shows me the text I get if i write "Bad" after it shows me the text I egt for the "good" option.
How can I make it so that the text you get for "bad" only shows up if you type anything else except the listed above?
sorry if its difficult to understand what I'm trying to say...
Last edited by Himekuri on Thu Oct 17, 2013 2:09 pm, edited 2 times in total.

User avatar
jesusalva
Regular
Posts: 88
Joined: Mon Jul 22, 2013 5:05 pm
Organization: Software in Public Interest, Inc.
IRC Nick: jesusalva
Github: pazkero
itch: tmw2
Location: Brazil
Discord: Jesusalva#4449
Contact:

Re: Having trouble with using a certain input?

#2 Post by jesusalva »

Modified to RenPy 6.15:

Code: Select all

    $ name = renpy.input("May I please take your name?", length=20) or "Noname"    
    # I modified the variable to renpy 6.15

    if name != "emily":        # if name different from "emily"
      jump start

    c "Nice to see you again [name] ."      # %(name)s is old. you can use brackets to do it.
You using an older version of ren'py. The right would be update.
But the

Code: Select all

    if name != "emily":
should work fine in your version.
Jesusaves/Jesusalva

Himekuri
Newbie
Posts: 8
Joined: Wed Oct 16, 2013 1:36 pm
Contact:

Re: Having trouble with using a certain input?

#3 Post by Himekuri »

jesusalva wrote:Modified to RenPy 6.15:

Code: Select all

    $ name = renpy.input("May I please take your name?", length=20) or "Noname"    
    # I modified the variable to renpy 6.15

    if name != "emily":        # if name different from "emily"
      jump start

    c "Nice to see you again [name] ."      # %(name)s is old. you can use brackets to do it.
You using an older version of ren'py. The right would be update.
But the

Code: Select all

    if name != "emily":
should work fine in your version.
Oh I see... thank you so much ! Also what would I need to write if I wanted more than one name to be accepted?

User avatar
jesusalva
Regular
Posts: 88
Joined: Mon Jul 22, 2013 5:05 pm
Organization: Software in Public Interest, Inc.
IRC Nick: jesusalva
Github: pazkero
itch: tmw2
Location: Brazil
Discord: Jesusalva#4449
Contact:

Re: Having trouble with using a certain input?

#4 Post by jesusalva »

Change

Code: Select all

    if name != "emily":
to

Code: Select all

    if ((name != "emily") and (name != "himekuri") and (name != "anna")):
That should do fine.

CAUTION! you've write the name in lower-case? then, if you write in upper-case, it is wrong. You are driven in start.

you can place "please, write in lower case" in the renpy.input text
OR
use:

Code: Select all

    $ name = renpy.input("May I please take your name?", length=20) or "Noname"   
    # I modified the variable to renpy 6.15
    $ name = name.lower()
That will work fine: lower() will change the input to lower-case. lower() is a python command, so it should work in older versions of ren'py.

I cannot grant that lower() will work 100% of times.

EDIT: changed "or" by "and" due "minor" errors.
Last edited by jesusalva on Wed Oct 16, 2013 4:48 pm, edited 1 time in total.
Jesusaves/Jesusalva

Himekuri
Newbie
Posts: 8
Joined: Wed Oct 16, 2013 1:36 pm
Contact:

Re: Having trouble with using a certain input?

#5 Post by Himekuri »

jesusalva wrote:Change

Code: Select all

    if name != "emily":
to

Code: Select all

    if ((name != "emily") or (name != "himekuri") or (name != "anna")):
That should do fine.

CAUTION! you've write the name in lower-case? then, if you write in upper-case, it is wrong. You are driven in start.

you can place "please, write in lower case" in the renpy.input text
OR
use:

Code: Select all

    $ name = renpy.input("May I please take your name?", length=20) or "Noname"   
    # I modified the variable to renpy 6.15
    $ name = name.lower()
That will work fine: lower() will change the input to lower-case. lower() is a python command, so it should work in older versions of ren'py.

I cannot grant that lower() will work 100% of times.
I'm sorry for coming with another problem but I changed it to

Code: Select all

 if ((name != "emily") or (name != "himekuri") or (name != "anna")):
but now regardless of what I enter it takes me back to start D:

User avatar
jesusalva
Regular
Posts: 88
Joined: Mon Jul 22, 2013 5:05 pm
Organization: Software in Public Interest, Inc.
IRC Nick: jesusalva
Github: pazkero
itch: tmw2
Location: Brazil
Discord: Jesusalva#4449
Contact:

Re: Having trouble with using a certain input?

#6 Post by jesusalva »

Oh, sorry, my error.
I've placed "or", but it should be "and". so the right is:

Code: Select all

 if ((name != "emily") and (name != "himekuri") and (name != "anna")):
Jesusaves/Jesusalva

Himekuri
Newbie
Posts: 8
Joined: Wed Oct 16, 2013 1:36 pm
Contact:

Re: Having trouble with using a certain input?

#7 Post by Himekuri »

jesusalva wrote:Oh, sorry, my error.
I've placed "or", but it should be "and". so the right is:

Code: Select all

 if ((name != "emily") and (name != "himekuri") and (name != "anna")):
Oh! Thank you so much !! First day of doing this and I already learnt so much haha :mrgreen:

User avatar
Taleweaver
Writing Maniac
Posts: 3428
Joined: Tue Nov 11, 2003 8:51 am
Completed: Metropolitan Blues, The Loyal Kinsman, Daemonophilia, The Dreaming, The Thirteenth Year, Adrift, Bionic Heart 2, Secrets of the Wolf, The Photographer
Projects: The Pilgrim's Path, Elspeth's Garden, Secret Adventure Game!
Organization: Tall Tales Productions
Location: Germany
Contact:

Re: Having trouble with using a certain input?

#8 Post by Taleweaver »

Wrong forum, buddy. Moving.
Scriptwriter and producer of Metropolitan Blues
Creator of The Loyal Kinsman
Scriptwriter and director of Daemonophilia
Scriptwriter and director of The Dreaming
Scriptwriter of Zenith Chronicles
Scriptwriter and director of The Thirteenth Year
Scriptwriter and director of Romance is Dead
Scriptwriter and producer of Adrift
More about me in my blog
"Adrift - Like Ever17, but without the Deus Ex Machina" - HigurashiKira

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Having trouble with using a certain input?

#9 Post by Elmiwisa »

There is a less painful way than typing (name!="something") every time. You can do:

Code: Select all

if name not in ["emily","himekuri","anna"]:
This is especially useful if there are too many allowed name that you cannot practically type out each one one-by-one. If there are very few number of allowed name, isn't it better if you just less the player choose one from a list instead of asking them to type? They most likely will get the name wrong and then end up having to retry many many times...

Himekuri
Newbie
Posts: 8
Joined: Wed Oct 16, 2013 1:36 pm
Contact:

Re: Having trouble with using a certain input?

#10 Post by Himekuri »

Elmiwisa wrote:There is a less painful way than typing (name!="something") every time. You can do:

Code: Select all

if name not in ["emily","himekuri","anna"]:
This is especially useful if there are too many allowed name that you cannot practically type out each one one-by-one. If there are very few number of allowed name, isn't it better if you just less the player choose one from a list instead of asking them to type? They most likely will get the name wrong and then end up having to retry many many times...
The thing is, the game I'm creating is quite different. When you open the game you're kind of playing as a character talking to the game therefore the game asks a question and you type back.
That's why I need to have lots of options.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Having trouble with using a certain input?

#11 Post by xela »

Himekuri wrote:
Elmiwisa wrote:There is a less painful way than typing (name!="something") every time. You can do:

Code: Select all

if name not in ["emily","himekuri","anna"]:
This is especially useful if there are too many allowed name that you cannot practically type out each one one-by-one. If there are very few number of allowed name, isn't it better if you just less the player choose one from a list instead of asking them to type? They most likely will get the name wrong and then end up having to retry many many times...
The thing is, the game I'm creating is quite different. When you open the game you're kind of playing as a character talking to the game therefore the game asks a question and you type back.
That's why I need to have lots of options.
He meant that

Code: Select all

if ((name != "emily") and (name != "himekuri") and (name != "anna")):
and

Code: Select all

if name not in ["emily", "himekuri", "anna"]:
do the same thing, only the latter is better readable and requires less typing. If you need to have a lot of options, checking membership in a container is better.
Like what we're doing? Support us at:
Image

Himekuri
Newbie
Posts: 8
Joined: Wed Oct 16, 2013 1:36 pm
Contact:

Re: Having trouble with using a certain input?

#12 Post by Himekuri »

xela wrote:
Himekuri wrote:
Elmiwisa wrote:There is a less painful way than typing (name!="something") every time. You can do:

Code: Select all

if name not in ["emily","himekuri","anna"]:
This is especially useful if there are too many allowed name that you cannot practically type out each one one-by-one. If there are very few number of allowed name, isn't it better if you just less the player choose one from a list instead of asking them to type? They most likely will get the name wrong and then end up having to retry many many times...
The thing is, the game I'm creating is quite different. When you open the game you're kind of playing as a character talking to the game therefore the game asks a question and you type back.
That's why I need to have lots of options.
He meant that

Code: Select all

if ((name != "emily") and (name != "himekuri") and (name != "anna")):
and

Code: Select all

if name not in ["emily", "himekuri", "anna"]:
do the same thing, only the latter is better readable and requires less typing. If you need to have a lot of options, checking membership in a container is better.
Oh I see !
oops :oops:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]