[solved] 2 main characters?

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
The King
Regular
Posts: 35
Joined: Fri Sep 25, 2020 12:37 pm
Completed: 0
Projects: LB
Contact:

[solved] 2 main characters?

#1 Post by The King » Thu Oct 08, 2020 11:53 pm

I don't really know what to call this, so I'm just calling it that for now at least. Here's my situation. I've been planning on a game with 2 characters, a brother and a sister, which acts as a gender selection for my game. I want to have both of them to have a default name they use if none is entered. After the player choose one of the characters, they can enter a name if they want, but I don't want them to be able to name the other character if they haven't picked them, but I'm willing to allow it if that's necessary. The default names I chose are Jack for male, and Erika for female. So if you picked male, you can name him, but I want the female to default to the name Erika, and vice versa if you picked female. Here's where the problem lies though. I picked a different name for the male, I chose Max, and his name displayed properly, but the girl's name displayed as: [girl_name] and I don't know why. Do I have to make it so the player names both of them, or is there a way to make it so the game automatically defaults to my chosen names unless the player names them themselves. Sorry if this sounds confusing, I'm not the best with articulating my point sometimes. Please let me know when you can, thank you. :)
Last edited by The King on Tue Oct 13, 2020 11:15 pm, edited 1 time in total.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

Re: 2 main characters?

#2 Post by hell_oh_world » Fri Oct 09, 2020 12:20 am

Code: Select all

define m_name_default = "Jack" # we define the default names
define f_name_default = "Erika"

default m_name = m_name_default # we assign the default names as the initial names during the start of the game
default f_name = f_name_default

define m = Character("[m_name]") # we use the name variables as the character names
define f = Character("[f_name]")

label name_input: # we create a label that we can call to input the name
  menu:
    "Male":
      $ is_male = True # we create and set a variable depending on the chosen gender
      
    "Female":
      $ is_male = False

  $ input = renpy.input("Choose a name (Blank means the default name): ").strip() # .strip() removes any trailing or leading white spaces in the user's input
  
  if is_male: # if gender is male we will assign the input to the m_name variable
    $ m_name = input if input else m_name_default # if input is not empty then use it, otherwise default to the default name

  else:
    $ f_name = input if input else f_name_default
      
  $ del is_male, input # we delete the variables since they were just temporarily used

  return

label start:
  call name_input # we call the label name_input to allow the user to pick names.
  "Male name: [m], Female name: [f]"
Looks like a lot, but this is what I thought of.

User avatar
The King
Regular
Posts: 35
Joined: Fri Sep 25, 2020 12:37 pm
Completed: 0
Projects: LB
Contact:

Re: 2 main characters?

#3 Post by The King » Fri Oct 09, 2020 3:37 pm

Okay, so I copied the code you wrote and pasted it into my game, and it seems to work well for both characters. Thank you for your help. :)

Post Reply

Who is online

Users browsing this forum: No registered users