Changing a variable from numerical to string[solved]

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
Mr. E
Regular
Posts: 139
Joined: Sat Apr 29, 2006 6:47 pm
Contact:

Changing a variable from numerical to string[solved]

#1 Post by Mr. E »

I would like to know if it's possible to assign a numerical variable to a string variable. A sketchy example follows:

Code: Select all

    $ number =+ 7
    $ word = "House" + number
    if word = "House7":
        'It worked!'
Last edited by Mr. E on Thu Mar 27, 2008 7:00 pm, edited 1 time in total.

Wintermoon
Miko-Class Veteran
Posts: 701
Joined: Sat May 26, 2007 3:41 pm
Contact:

Re: Changing a variable from numerical to string

#2 Post by Wintermoon »

Code: Select all

$ word = "House%s" % number # The placeholder-substitution method.
$ word = "House" + str(number) # The simple, direct method.

Mr. E
Regular
Posts: 139
Joined: Sat Apr 29, 2006 6:47 pm
Contact:

Re: Changing a variable from numerical to string[solved]

#3 Post by Mr. E »

Thanks for the help, wintermoon. I knew it was simple but it was still bugging me for the last hour or so...

Post Reply

Who is online

Users browsing this forum: decocloud