Page 1 of 1

[SOLVED] Dynamic Say window background not changing

Posted: Thu Feb 05, 2015 12:23 am
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!

Re: Dynamic Say window background not changing

Posted: Thu Feb 05, 2015 12:38 am
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.

Re: Dynamic Say window background not changing

Posted: Thu Feb 05, 2015 3:31 pm
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.

Re: Dynamic Say window background not changing

Posted: Thu Feb 05, 2015 3:43 pm
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"
    )

Re: Dynamic Say window background not changing

Posted: Thu Feb 05, 2015 4:02 pm
by webryder
*smacks head*

It works!

Thanks for the help!