How do I show a character that's a 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
ranshaa05
Newbie
Posts: 1
Joined: Wed Jan 15, 2020 4:37 pm
Contact:

How do I show a character that's a variable?

#1 Post by ranshaa05 »

I'm writing a scenario for "Student Transfer" and it requires me to add a suffix in the code in order to reference a character that only exists in my scenario.
the suffix i chose is "s" so every time i need to reference my character i need to write "s_ran". i thought i could write something like this so i won't have to use the suffix every time:

Code: Select all

# Naming
    python:
        #Ran
        ran = s_ran
        
ran "hi again" 
show ran a_0
but for some reason, the say statement works fine while the show statement brings up the default character picture and not the picture i want it to display, and when i type

Code: Select all

show s_ran a_0
it does.
it's not really a big deal but why does this happen? can i work around it somehow?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: How do I show a character that's a variable?

#2 Post by xavimat »

You can use brackets to use a variable in image names: https://renpy.org/doc/html/displayables ... splayables
You can use also show expression https://renpy.org/doc/html/displaying_i ... -statement,
Also, be careful not using the same variable name for characters and sprites (you are using too many ran). Renpy will get confused.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]