customized responses based on player 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
User avatar
lunakohl
Newbie
Posts: 4
Joined: Tue Feb 05, 2019 12:43 pm
Contact:

customized responses based on player input

#1 Post by lunakohl » Sun Feb 24, 2019 12:56 pm

At the beginning of my game as a joke I prompt the player to input their name but then later issue them a predetermined name, sort of like Toby Fox's Deltarune.
I'm a complete coding amateur so I'm not sure if there's a way to do this in this program, but I was wondering if there was any way to customize my game's response to what the player types in.

For example, if they typed in the name of a pre-existing character, is there a way I could show only certain scenes, or end the game immediately?
Or at least not allow them to input the name I will assign them?

Here is the code I'm using for reference:

Code: Select all

define pov = Character("[povname]")

    python:
        povname = renpy.input("So. What is your name?")
        povname = povname.strip()

    "Nice to meet you, [povname]."
:D

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: customized responses based on player input

#2 Post by isobellesophia » Mon Feb 25, 2019 12:12 am

Code: Select all

define pov = Character("[povname]") 
python: 
povname = renpy.input("So. What is your name?") 
povname = povname.strip(allow=None) 
"Nice to meet you, [povname]."

Code: Select all

define pov = Character("[povname]") 
python: 
povname = renpy.input("So. What is your name?") 
povname = povname.strip() 
"Nice to meet you, [povname]." 
$ renpy.quit()
Sorry for the line indention, i am currently using a tablet.
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: customized responses based on player input

#3 Post by xavimat » Tue Feb 26, 2019 2:24 pm

povname is a variable. You can use "if/elif/else" to check anything with it.
(don't need the "python" part, put them inside a label with $ at the begining of the lines)

Code: Select all

define pov = Character("[povname]")
label set_povname:
    $ povname = renpy.input("So. What is your name?").strip()
    if povname == "Eileen":
        "Eileen" "That can't be possible, I AM Eileen, not you."
        jump set_povname
    elif povname == "Lucy":
        "Eileen" "Oh, no, I know Lucy, and you are not her."
        jump set_povname
    "Nice to meet you, [povname]."
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
lunakohl
Newbie
Posts: 4
Joined: Tue Feb 05, 2019 12:43 pm
Contact:

Re: customized responses based on player input

#4 Post by lunakohl » Tue Feb 26, 2019 3:52 pm

Thank you guys so much!
:D

Post Reply

Who is online

Users browsing this forum: nyeowmi