How to make it so if you name yourself a certain word it changes the outcome?

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
cookiepawz
Newbie
Posts: 2
Joined: Sun Mar 17, 2019 9:02 am
Contact:

How to make it so if you name yourself a certain word it changes the outcome?

#1 Post by cookiepawz »

Hi! I'm new to making visual novels and I need help with something
How do I make it so that if you name yourself a certain name in the game, it will take you to a different path? I tried this code but it keeps giving an error.

Code: Select all


define c = Character('Coki', color="#FF6600")
define m = Character("[mename]", color="#0099FF")

python:
    mename = renpy.input("What's your name?")
    mename = mename.strip()

    if not mename:
         mename = "Anon"
         
m "My name is [mename]"
if mename = "Coki":
    jump namefail
    
c "Well nice to meet you [mename], I guess..."
jump namepass

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: How to make it so if you name yourself a certain word it changes the outcome?

#2 Post by strayerror »

Equality operations (testing one thing is equal to another) in python use ==. In your example you're using a single = which denotes assignment, so instead of testing that mename is equal to "Coki" you're telling python to change the value of mename to be "Coki". Python doesn't allow assignments inside if statements which is why you're seeing an invalid syntax error. Try this:

Code: Select all

if mename == "Coki":


Post Reply

Who is online

Users browsing this forum: Google [Bot]