[SOLVED] Dynamic Say window background not changing

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
webryder
Regular
Posts: 40
Joined: Thu Feb 06, 2014 9:46 pm
Contact:

[SOLVED] Dynamic Say window background not changing

#1 Post by webryder »

Hi all,

I'm using speech bubbles at the top of my screen for say windows instead of the text box at the bottom. That's working fine. The problem is that I use a different speech bubble background based on where the character is on the screen. For example, if the character is centered he uses a different box than when he's on the left. Here's how I have it set up...

Code: Select all

define hiroshi = Character(None, window_background = SpeechBubble)

init -5 python:
    SpeechBubble = "art/gui/SpeechBubble_Center.png"
That works fine for giving everyone the centered speech bubble. The problem comes up when I try to change it within the game. Let's say I am in a scene where Hiroshi is at the left and I want him to use the left Speech Bubble. I coded it like this...

Code: Select all

    show hiroshi smile2 at left
    
    $ SpeechBubble = "art/gui/SpeechBubble_Left.png"

    hiroshi "I am using the wrong speech bubble!"
In this case the speech bubble does not change, and he keeeps using the centered speech bubble instead of the left one. I'm not getting any errors, but the say window doesn't change.

Does anybody have any ideas on what I am doing wrong here?

Thanks!
Last edited by webryder on Thu Feb 05, 2015 4:03 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Dynamic Say window background not changing

#2 Post by philat »

Would say you're probably looking for ConditionSwitch. http://lemmasoft.renai.us/forums/viewto ... 51&t=19063

Something along the lines of SpeechBubble = ConditionSwitch("position == 'left'", "left.png", "position == 'center'", "center.png") and so forth.

webryder
Regular
Posts: 40
Joined: Thu Feb 06, 2014 9:46 pm
Contact:

Re: Dynamic Say window background not changing

#3 Post by webryder »

Hmmm, ConditionSwitch is giving me errors.

I put it in like this (based on the ConditionSwitch tutorial you linked):

Code: Select all

image SpeechBubble = ConditionSwitch(
    "sb_direction = 'left'", "art/gui/SpeechBubble_Left.png",
    "sb_direction = 'right'", "art/gui/SpeechBubble_Left.png",
    "True", "art/gui/SpeechBubble_Center.png"
    )

define hiroshi = Character(None, window_background = 'SpeechBubble')
That line with "True" keeps giving me a syntax error. I changed it to "sb_direction = 'center'" and still got the syntax error. I also tried putting a comma after that last line and still got invalid syntax.

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Dynamic Say window background not changing

#4 Post by philat »

I don't know why it's flagging the True line, but the invalid syntax is in the conditions before that. You need to use two equals signs to check for equivalence.

Code: Select all

image SpeechBubble = ConditionSwitch(
    "sb_direction == 'left'", "art/gui/SpeechBubble_Left.png",
    "sb_direction == 'right'", "art/gui/SpeechBubble_Left.png",
    "True", "art/gui/SpeechBubble_Center.png"
    )

webryder
Regular
Posts: 40
Joined: Thu Feb 06, 2014 9:46 pm
Contact:

Re: Dynamic Say window background not changing

#5 Post by webryder »

*smacks head*

It works!

Thanks for the help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]