Variables and the Text function

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
ShiraiJunichi
Miko-Class Veteran
Posts: 651
Joined: Sat May 21, 2005 12:28 pm
Location: University of Utah
Contact:

Variables and the Text function

#1 Post by ShiraiJunichi » Sat Mar 03, 2007 4:24 pm

I would like to use:

Code: Select all

show expression Text("It's day %(day)d.", yalign=0.5, xalign=0.5, drop_shadow=(2, 2)) as text with dissolve
to display the day- but it doesn't interpret the variable "day"...

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#2 Post by PyTom » Sat Mar 03, 2007 4:32 pm

In python code (which that is), you need to use Python's string interpolation syntax:

Code: Select all

show expression Text("It's day %d." % day, yalign=0.5, xalign=0.5, drop_shadow=(2, 2)) as text with dissolve
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Google [Bot]