Switch cannot choose a displayable error? [SOLVED]

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
nukedeggs
Newbie
Posts: 4
Joined: Fri Jan 16, 2015 10:41 pm
Soundcloud: nukedeggs
Contact:

Switch cannot choose a displayable error? [SOLVED]

#1 Post by nukedeggs »

Hello all. So in my game I want to display side-images next to the dialogue box, and I have a lot of side-images that I sometimes add more to. My usual procedure when adding a new side-image is to reload Ren'Py, start a new game, and then play through to see if it works. Recently I added a few new side images, but unfortunately, I keep getting a 'Switch Cannot Choose A Displayable Image'. Here is the code in question:

Code: Select all

    
init:
    $ flash = Fade(.25, 0, .75, color="#fff")
    $ redflash = Fade(.25, 0, .75, color="#FF0000")
    $ mood = 0
    $ e = Character('Parker', color='#009933', \
        show_side_image=ConditionSwitch('mood==0', 'par_smile', 
        'mood==1', 'par_surp_frown', \
        'mood==2', 'par_smile_talk', \
        'mood==3', 'par_frown', \
        'mood==4', 'par_blush_smile', \
        'mood==5', 'par_open_mad', \
        'mood==6', 'par_surp_smile', \
        'mood==7', 'par_blush', \
        'mood==8', 'par_sheep_blush', \
        'mood==9', 'par_determined', \
        'mood==10', 'par_norm_frown', \
        'mood==11', 'par_closedeye_blush', \
        'mood==12', 'par_lidded_blush_smile', \
        'mood==13', 'par_sleepy', \
        'mood==14', 'par_sleepy_frown', \
        'mood==15', 'par_crying', \
        'mood==16', 'par_bitter', \
        'mood==17', 'ke_frown', \
        'mood==18', 'ke_smile', \
        'mood==19', 'ke_surp', \
        'mood==20', 'ke_open_surp', \
        xalign=0, yalign=1.0), window_left_padding=210)

label start:
        $mood = 17
        e "Test"
So everything up to Mood==16 works. I recently added the four 'ke' images and went about the process of restarting the game and starting a new game. However, when I try to switch to that mood, I get a 'Switch cannot choose a displayable' error. For those who are interested, here is the stacktrace:

Code: Select all

I'm sorry, but an uncaught exception occurred.

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

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

Full traceback:
  File "game/script.rpy", line 189, in script
    e "test"
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\ast.py", line 558, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\exports.py", line 925, in say
    who(what, interact=interact)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\character.py", line 817, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\character.py", line 683, in do_display
    **display_args)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\character.py", line 462, in display_say
    what_text = show_function(who, what_string)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\character.py", line 667, in do_show
    **self.show_args)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\character.py", line 272, in show_display_say
    return renpy.display.screen.get_widget(screen, "what", layer)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\screen.py", line 646, in get_widget
    screen.update()
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\screen.py", line 296, in update
    self.child.visit_all(lambda c : c.per_interact())
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\core.py", line 306, in visit_all
    d.visit_all(callback)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\core.py", line 306, in visit_all
    d.visit_all(callback)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\core.py", line 308, in visit_all
    callback(self)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\screen.py", line 296, in <lambda>
    self.child.visit_all(lambda c : c.per_interact())
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\layout.py", line 1013, in per_interact
    child, _ = self.function(self.st, self.at, *self.args, **self.kwargs)
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\layout.py", line 1079, in condition_switch_show
    return condition_switch_pick(switch), None
  File "C:\Users\egg\Documents\renpy-6.17.6-sdk\renpy\display\layout.py", line 1076, in condition_switch_pick
    raise Exception("Switch could not choose a displayable.")
Exception: Switch could not choose a displayable.

Windows-post2008Server-6.2.9200
Ren'Py 6.17.6.512
If anyone has any insight, I would seriously appreciate it. Thanks everyone!
Last edited by nukedeggs on Wed Jun 10, 2015 7:41 pm, edited 3 times in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Switch cannot choose a displayable error?

#2 Post by PyTom »

I'd suggest adding code like:

Code: Select all

define e = Character('Euls', color='#009933', \
        show_side_image=ConditionSwitch('mood==0', 'eul_smile', 
        'mood==1', 'eul_surp_frown', \
        'mood==2', 'eul_smile_talk', \
        'mood==3', 'eul_frown', \
        'mood==4', 'eul_blush_smile', \
        'mood==5', 'eul_open_mad', \
        'mood==6', 'eul_surp_smile', \
        'mood==7', 'eul_blush', \
        'mood==8', 'eul_sheep_blush', \
        'mood==9', 'eul_determined', \
        'mood==10', 'eul_norm_frown', \
        'mood==11', 'eul_closedeye_blush', \
        'mood==12', 'eul_lidded_blush_smile', \
        'mood==13', 'eul_sleepy', \
        'mood==14', 'eul_sleepy_frown', \
        'mood==15', 'eul_crying', \
        'mood==16', 'eul_bitter', \
        'mood==17', 'ke_frown', \
        'mood==18', 'ke_smile', \
        'mood==19', 'ke_surp', \
        'mood==20', 'ke_open_surp', \
        'True', Text("[mood]", size=100),
        xalign=0, yalign=1.0), window_left_padding=210)
The define (which should be at the top level, before label start, replacing the $ e = line) will ensure e is defined at init time. I don't know if this is the problem, but it's possible e is being saved and loaded, which could cause this problem. Remember to start a new game.

The 'True' line will mean that if no other condition is chosen, the number of the mood will be displayed - which should tell us something about the problem, if the former code doesn't fix it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
nukedeggs
Newbie
Posts: 4
Joined: Fri Jan 16, 2015 10:41 pm
Soundcloud: nukedeggs
Contact:

Re: Switch cannot choose a displayable error?

#3 Post by nukedeggs »

Hmm I do that in the init block and I still get the same error...where is the number of the mood supposed to be displayed?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Switch cannot choose a displayable error?

#4 Post by PyTom »

It should be displayed on the screen, where the character would be.

Are you starting your game over? You need to, since your old savegames have the e character saved in them.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
nukedeggs
Newbie
Posts: 4
Joined: Fri Jan 16, 2015 10:41 pm
Soundcloud: nukedeggs
Contact:

Re: Switch cannot choose a displayable error?

#5 Post by nukedeggs »

Yeah I deleted my persistent data and started a new game, but I'm still getting the error. Not quite sure why the init block is being so finicky...

EDIT: I also tried changing mood=16 (which works) to ke_frown, but it still displays par_bitter. I also tried swapping it out for 'par_crying', but it still displays par_bitter even if I start a new game and delete persistent data.
Last edited by nukedeggs on Wed Jun 10, 2015 7:41 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Switch cannot choose a displayable error?

#6 Post by PyTom »

Can you post your full code somewhere? I'm having trouble understanding what's wrong.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
nukedeggs
Newbie
Posts: 4
Joined: Fri Jan 16, 2015 10:41 pm
Soundcloud: nukedeggs
Contact:

Re: Switch cannot choose a displayable error?

#7 Post by nukedeggs »

EDIT: Wait, nevermind. I fixed it. I think the problem was that I have two inits in two different script files and I think that perhaps the other init is taking precedence over the init in script.rpy. Thanks for the help!!

Post Reply

Who is online

Users browsing this forum: No registered users