Side Images Not Appearing With Variable Styled Names!

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
jac600
Newbie
Posts: 17
Joined: Thu Apr 19, 2018 5:04 pm
Github: Dalton
Soundcloud: White
Contact:

Side Images Not Appearing With Variable Styled Names!

#1 Post by jac600 »

Howdy everybody! A friend of mine has been giving it his all making a Ren'Py system for a super in depth game recently. But he's ran into a wall I want to help him with.

The objective is to make a variable name that displays a side image for the name currently filling that variable.

Whenever a character speaks their side image is suppose to appear, however with the code (detailed below) this image does not appear when the name is a variable rather than a specific value. I.E. If the name called upon is: Amanda. It shows up great. But if it's a variable that is equal to Amanda, no dice. Thank you all for your time.


label start:
#Defining Amanda & Side Image
define Amanda = Character("Amanda", window_left_padding=165, image="Amanda")
image side Amanda = im.FactorScale("side_Amanda.png", 0.5, 0.5)

#Designating Neutral Variable
$ name = "Amanda"

#Displays Side Image Properly
Amanda "Hello"

#Does Not Display Side Image
name "Hello"

#Displays Side Image Properly
Amanda "Hello"
return

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Side Images Not Appearing With Variable Styled Names!

#2 Post by rayminator »

put theses above label start

Code: Select all

define Amanda = Character("Amanda", window_left_padding=165, image="Amanda")
image side Amanda = im.FactorScale("side_Amanda.png", 0.5, 0.5)

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Side Images Not Appearing With Variable Styled Names!

#3 Post by Alex »

This happened 'cause you can show some text without declaring a character first, like

Code: Select all

"some_name" "Heloo..."
So,

Code: Select all

$ name = "Amanda"
assigns the text value to variable 'name'.

And

Code: Select all

name "Hello"
just shows "Hello" by undeclared character with name stored in variable 'name'.

Try

Code: Select all

$ name = Amanda # pre-defined character without quotes

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Side Images Not Appearing With Variable Styled Names!

#4 Post by kivik »

As alex said, what you want is to actually store the character in the variable, not the name. If there’s a reason you need go bring up a character by the name as string for any reason, then you may want to use a dict. After you’ve setup the Amanda character:

Code: Select all

npc = {“Amanda”: Amanda}
$ name = “Amanda”
npc[name] “hello world”
That should work because npc[“Amanda”] is the Amanda character.

jac600
Newbie
Posts: 17
Joined: Thu Apr 19, 2018 5:04 pm
Github: Dalton
Soundcloud: White
Contact:

Re: Side Images Not Appearing With Variable Styled Names!

#5 Post by jac600 »

Thanks everybody! You replied super fast and were able to help out. My friend was skeptical, but your solution did solve his problem Alex! All of you have an awesome day.

Post Reply

Who is online

Users browsing this forum: Kocker, Semrush [Bot]