Events for specific names

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Karunakku
Newbie
Posts: 7
Joined: Sun Nov 15, 2015 12:03 am
Contact:

Events for specific names

#1 Post by Karunakku »

So, I found how to make special things happen when you choose sepcial names. This can be used when the player chooses the name of someone special to the MC(They could talk to you like they would to this person, considering you are them!), for easter eggs(Ex:. You write Poop and the game tells you you're immature and you go back to the name menu) or it could be used so the player can't use the name of an existing character.

I don't even know how to explain it, so I put some basic explanation in the code itself:

Code: Select all

p "Hey, my name is Potato!"

    $ player_name = renpy.input("And you, what's your name?") #Name insert is here

    $ player_name = player_name.strip() 

    if player_name == "":
        $ player_name= "Mashed boi" #This is the name you will have if you enter nothing
        $ name="other"
    if player_name == "Fries": 
        $ name="secret"  #The access to the secret dialogue because of your name
    if player_name == "fries": 
        $ name="secret" #Also avaible without the caplocks
    else: 
        $ name="other" #When you enter anything else
        
    if name == "secret": #You enter this anytime you want a secret dialogue
        p "Oh, h-hey Fries senpai!" 
    if name == "other": #And this for the average ones
        p "I didn't even know other things than potatoes were a thing!"
After some bug checking, I discovered that the blank space name only stays unbothered when you put it first. Or else your secret names won't work!
Last edited by Karunakku on Sat Oct 08, 2016 8:36 pm, edited 1 time in total.

User avatar
Katy133
Miko-Class Veteran
Posts: 704
Joined: Sat Nov 16, 2013 1:21 pm
Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
Projects: The Butler Detective
Tumblr: katy-133
Deviantart: Katy133
Soundcloud: Katy133
itch: katy133
Location: Canada
Contact:

Re: Events for specific names

#2 Post by Katy133 »

I've made a tutorial for that here too, if the screenshots help. :)
ImageImage

My Website, which lists my visual novels.
Become a patron on my Patreon!

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Events for specific names

#3 Post by Divona »

Karunakku wrote:You write Poop and the game tells you you're immature and you go back to the name menu
Push it to the next level. Set:

Code: Select all

define persistent.worthless = False
......
if player.name == "Poop" or player.name == "poop":
    p "You're immature. I don't want to talk to you anymore!"
    $ persistent.worthless = True
    $ renpy.quit()
and then...

Code: Select all

label start:
    if persistent.worthless == True:
        p "You're immature. Go away!"
        $ renpy.quit()
......
Oh, I'm so evil. Don't try this at home. :twisted:

You can also do:

Code: Select all

if player.name[:4].lower() == "poop":
So it doesn't matter if player name their character "Poopalicious" or "Poopmaster", it will always trigger. :lol:
Completed:
Image

Katherine
Newbie
Posts: 17
Joined: Mon Oct 31, 2016 2:27 pm
Contact:

Re: Events for specific names

#4 Post by Katherine »

Divona wrote:
Karunakku wrote:You write Poop and the game tells you you're immature and you go back to the name menu
Push it to the next level. Set:

Code: Select all

define persistent.worthless = False
......
if player.name == "Poop" or player.name == "poop":
    p "You're immature. I don't want to talk to you anymore!"
    $ persistent.worthless = True
    $ renpy.quit()
and then...

Code: Select all

label start:
    if persistent.worthless == True:
        p "You're immature. Go away!"
        $ renpy.quit()
......
Oh, I'm so evil. Don't try this at home. :twisted:

You can also do:

Code: Select all

if player.name[:4].lower() == "poop":
So it doesn't matter if player name their character "Poopalicious" or "Poopmaster", it will always trigger. :lol:
would this also work if they tried a set of combinations of capital and lower case? (example would "PoOp, POOP, poop, etc." be treated the exact same? or would I have to code for all of those?)

Katherine
Newbie
Posts: 17
Joined: Mon Oct 31, 2016 2:27 pm
Contact:

Re: Events for specific names

#5 Post by Katherine »

okay I tried this using my own names and got the following error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 89, in script
    if name == "other":
  File "game/script.rpy", line 89, in <module>
    if name == "other":
NameError: name 'name' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 89, in script
    if name == "other":
  File "C:\Users\Katherine\Downloads\renpy-6.99.11-sdk\renpy\ast.py", line 1647, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\Katherine\Downloads\renpy-6.99.11-sdk\renpy\python.py", line 1670, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\Katherine\Downloads\renpy-6.99.11-sdk\renpy\python.py", line 1665, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 89, in <module>
    if name == "other":
NameError: name 'name' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.11.1749
Blood of Betrayal 1.0
here is my script for the section. maybe I typed something in wrong?

Code: Select all

label start:
   
    $ Damien_Points = 0
    $ Matthew_Points = 0
    $ Sam_Points = 0
    $ Erik_Points = 0
    $ James_Points = 0
    $ Energy_Points = 75
    $ Sanity_Points = 90
    $ Family_Points = 0
    $ Transform_Points = 0
    $ player_name = renpy.input("What is your name?")
    $ player_name = player_name.strip()
    if player_name == "":
        $ player_name= "Katherine"
        $ name="other"
    if player_name [:4].lower == "mika":
        $ name="secret"
    if name == "other":
        jump story
    if name == "secret":
      if persistent.mika1== false:
          P "Huh . . ?"
          P "Who are you?"
          P "It doesn't matter."
          P "Just go away."
          P "I don't want to relive what that monster did to me."
          $ persistent.mika1 = true
          return
      elif persistent.mika2== false:
          P "Wha-?"
          P "Why are you back?"
          P "Don't you understand that I don't want to talk?"
          P "Just leave me alone."
          $ persistent.mika2 = true          
          return
      elif persistent.mika3 == false:
          P ". . ."
          return

Post Reply

Who is online

Users browsing this forum: No registered users