[SOLVED] Can't get Side Image to work with Condition Switch

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
Lucia
Newbie
Posts: 9
Joined: Wed Dec 11, 2013 1:18 pm
Contact:

[SOLVED] Can't get Side Image to work with Condition Switch

#1 Post by Lucia » Fri Jan 24, 2014 6:40 pm

Hi,

I am having issues with getting Condition Switch to work for dynamic side images. I looked up code on various sites, including the forum, even copypasted the code but I always get the same error when I try to load the script.

First, this is my character talk code:

Code: Select all

    # Image on the side.
    $ n = Character('Mila',
          color="#680a56",
          what_color="#2f0d3a",
          window_left_padding=160,
          show_side_image=ConditionSwitch(
          "mc_exp == 'sad'", "assets/talk/mila_talk_side_sad.png",
          "mc_exp == 'happy'", "assets/talk/mila_talk_side_happy.png",
          "mc_exp == 'True'", "assets/talk/mila_talk_side_neutral.png", xalign=0.0, yalign=1.0
        )
    )
(also tried == sad", without ' ' )

Variable:

Code: Select all

label start:
#Character display states
    $ dressset = 0
    $ mc_exp = True
This is the error I am getting, I don't know what's wrong.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 167, in script
Exception: Switch could not choose a displayable.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\ast.py", line 455, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\exports.py", line 803, in say
    who(what, interact=interact)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\character.py", line 807, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\character.py", line 673, in do_display
    **display_args)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\character.py", line 452, in display_say
    what_text = show_function(who, what_string)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\character.py", line 657, in do_show
    **self.show_args)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\character.py", line 263, in show_display_say
    return renpy.display.screen.get_widget(screen, "what")
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\screen.py", line 620, in get_widget
    screen.update()
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\screen.py", line 274, in update
    self.child.visit_all(lambda c : c.per_interact())
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\core.py", line 246, in visit_all
    d.visit_all(callback)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\core.py", line 246, in visit_all
    d.visit_all(callback)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\core.py", line 248, in visit_all
    callback(self)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\screen.py", line 274, in <lambda>
    self.child.visit_all(lambda c : c.per_interact())
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\layout.py", line 1009, in per_interact
    child, _ = self.function(self.st, self.at, *self.args, **self.kwargs)
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\layout.py", line 1075, in condition_switch_show
    return condition_switch_pick(switch), None
  File "J:\RENPY\renpy-6.16.2-sdk\renpy\display\layout.py", line 1072, in condition_switch_pick
    raise Exception("Switch could not choose a displayable.")
Exception: Switch could not choose a displayable.

Windows-7-6.1.7601-SP1
Ren'Py 6.16.3.502
WrProject 0.1
I tried to change mc_exp to True, neutral, used numbers... to no avail. I do not know what I've done wrong.
Last edited by Lucia on Mon Jan 27, 2014 3:11 pm, edited 1 time in total.

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: Can't get Side Image to work with Condition Switch

#2 Post by Crazy Li » Fri Jan 24, 2014 7:03 pm

$ mc_exp = True

would logically not test as true for

mc_exp == 'True'

since the first is a boolean and the second is a string. I'm not sure why it's not working for neutral or numbers though, but I'd need to see the code for that as well.

It may also be wise to define "mc_exp" in an init above everything else for a default value instead of waiting until the game starts.

User avatar
Lucia
Newbie
Posts: 9
Joined: Wed Dec 11, 2013 1:18 pm
Contact:

Re: Can't get Side Image to work with Condition Switch

#3 Post by Lucia » Sat Jan 25, 2014 8:36 am

My gosh, thanks a lot Crazy Li! Your hint at $ mc_exp being a bolean while mc_exp == 'True' is a string helped me a lot!

I changed it to:

Code: Select all

    $ mc_exp = 'neutral'
Also, I declared the variable in the

Code: Select all

init:
section.

code for side is:

Code: Select all

    $ n = Character('Mila',
          color="#680a56",
          what_color="#2f0d3a",
          window_left_padding=220,
          show_side_image=ConditionSwitch(
          "mc_exp == 'sad'", "assets/talk/mila_talk_side_sad.png",
          "mc_exp == 'happy'", "assets/talk/mila_talk_side_happy.png",
          "mc_exp == 'neutral'", "assets/talk/mila_talk_side_neutral.png", xalign=0.0, yalign=1.0,
        )
    )
Thanks again! I wonder why it didn't worked with a number check though...

To change the side image I use:

Code: Select all

    $ mc_exp ='neutral' 
and it works.

Post Reply

Who is online

Users browsing this forum: Google [Bot]