[SOLVED]How to add characters to an already defined variable

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
PhZXgames
Regular
Posts: 49
Joined: Fri Oct 14, 2016 2:12 pm
Completed: Character Creation Frame
Projects: RWBY Dawnfall
Organization: PhZX Games
Skype: live:phzxgames
Location: Minnesota, USA
Contact:

[SOLVED]How to add characters to an already defined variable

#1 Post by PhZXgames »

So I kinda want to know this for future reference, but how on earth do you add characters (letters, numbers, symbols, spaces) to an already defined variable? Like I want the player's name to be whatever they want it to be, but with a fixed last name for story purposes. so like, if someone, per say, a teacher were to call them by their full name, ("player_name Reia") how would you do that?

I used a basic renpy.input line for the player to put in any name they want. This sets the name they chose to the variable "Player_name". the second line just removes any spaces at the end.

Code: Select all

    $ player_name = renpy.input("What is your name?")

    $ player_name = player_name.strip()
And I already took a stab at it, by using this line, which failed miserably:

Code: Select all

$ player_name_full = player_name.add( Reia)
Specifically I got this error message:
AttributeError: 'str' has no attribute 'add'

One, what does /|\ that mean and two how would I do what I'm trying to do? Thanks!
Last edited by PhZXgames on Sun Dec 25, 2016 8:04 pm, edited 1 time in total.
"Don't Explode!"
-me

KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: How to add characters to an already defined variable

#2 Post by KimiYoriBaka »

An attribute is anything a python object might have as part of it. In the case of that message, it's just telling you that python strings (called by the class name str) don't have an add() function. The technical term for what you're trying to do is "concatenate", which just means to combine strings together. In python (and thus in renpy, and pretty much all languages I've seen used for scripting) you can add them together like numbers. Just remember that strings go in quotation marks.

Code: Select all

$ player_name_full = player_name + " Reia"

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], bonnie_641