My Side Image Won't Stay...

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
Hurricanedragon
Newbie
Posts: 8
Joined: Wed Dec 10, 2014 1:47 pm
Deviantart: Hurricanedragon
Contact:

My Side Image Won't Stay...

#1 Post by Hurricanedragon » Sat Oct 10, 2015 12:33 pm

Hello.
I tried using this topic (http://lemmasoft.renai.us/forums/viewto ... =8&t=17939) to help me make my side image stay, but my code doesn't seem to work at all.

In my "say" screen, I have:

Code: Select all

# If there's a side image, display it above the text.
   
    default noMC = False
    
    if noMC:
        if side_image:
            add side_image
        else:
            add SideImage() xalign 1.0 yalign 1.0

    else:
        add "sariya_side" xalign 1.0 yalign 1.0
And in my script, I have:

Code: Select all

init:
    image sariya_side = ConditionSwitch(
        "sa == 'wnormal'", "Sariya/Sari_W_Normal.png"
        "sa == 'whappy'", "Sariya/Sari_W_Happy.png"
        "sa == 'wderp'", "Sariya/Sari_W_Derp.png"
        "sa == 'wlove'","Sariya/Sari_W_Love.png"
        "sa == 'wmad'", "Sariya/Sari_W_Mad.png"
        "sa == 'wangry'", "Sariya/Sari_W_Angry.png"
        "sa == 'wsad'", "Sariya/Sari_W_Sad.png"
        "sa == 'wyay'", "Sariya/Sari_W_Yay.png"
        "sa == 'wsorry'", "Sariya/Sari_W_Sorry.png"
        "sa == 'wupset'", "Sariya/Sari_W_Upset.png"
        "sa == 'wproud'", "Sariya/Sari_W_Proud.png"
        "sa == 'welated'", "Sariya/Sari_W_Elated.png"
        "sa == 'wcute'", "Sariya/Sari_W_Cute.png"
        "sa == 'wconfused'", "Sariya/Sari_W_Confused.png"
        "sa == 'wemba'", "Sariya/Sari_W_Embarrassed.png"
    )
# Declare characters used by this game.


##Sariya
define sa = Character('Sariya', color="#FFFFFF", what_prefix='"', 
    what_suffix='"', show_two_window=True)
When I start the game to see if it worked, I keep getting traceback files that say:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 195, in script
    centered "{color=#fff}{i}RING-DING DING-DONG.{/i}{/color}"
NameError: name 'Sariya' is not defined
...when the character, Sariya, isn't even supposed to speak there.


Can someone tell me what I'm doing wrong?

User avatar
Steamgirl
Veteran
Posts: 322
Joined: Sat Jul 28, 2012 4:39 am
Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
Projects: Stranded Hearts, Emma: A Lady's Maid
Deviantart: steamgirlgame
Contact:

Re: My Side Image Won't Stay...

#2 Post by Steamgirl » Sat Oct 10, 2015 1:23 pm

Could you copy the script.rpy lines 190-200? Just to see what is around it as well, sometimes it can give a hint about the problem.
Also, did you happen to overwrite centered? If so, would be good to see that too. :)

User avatar
Hurricanedragon
Newbie
Posts: 8
Joined: Wed Dec 10, 2014 1:47 pm
Deviantart: Hurricanedragon
Contact:

Re: My Side Image Won't Stay...

#3 Post by Hurricanedragon » Sat Oct 10, 2015 1:28 pm

Code: Select all

label start:

    scene black
    window show
    
    centered "{color=#fff}{i}RING-DING DING-DONG.{/i}{/color}"
    centered "{color=#fff}{i}DING-DING RING-DONG.{/i}{/color}"
    
    "The bells ring their familiar chime, signalling students to head towards their homerooms as the school day begins again."
    
    "Some students may find this repeating cycle boring, but I don't mind."
    
    "After all..."
The label is line 187, and line 190 starts where "window show" is.

User avatar
Steamgirl
Veteran
Posts: 322
Joined: Sat Jul 28, 2012 4:39 am
Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
Projects: Stranded Hearts, Emma: A Lady's Maid
Deviantart: steamgirlgame
Contact:

Re: My Side Image Won't Stay...

#4 Post by Steamgirl » Sat Oct 10, 2015 1:49 pm

Hmmm... The problem must be somewhere else. Do you still get this error when you comment out the show window statement? (Though I see no reason why that would cause a problem).
Did you overwrite the centered Character by any chance?
EDITED TO ADD: It's almost as if you did "define centered Character(Sariya, bla bla bla)" without adding the ' marks to Sariya. That's what the error looks like to me without seeing more of the code.

Also, it's probably not related, but is there a reason why you didn't go for the usual approach to side images?

IE

Code: Select all

image side sariya normal = "Sariya/Sari_W_Normal.png"
image side sariya happy = "Sariya/Sari_W_Happy.png"
image side sariya derp = "Sariya/Sari_W_Derp.png"

define sa = Character('Sariya', image="sariya", color="#FFFFFF", what_prefix='"', what_suffix='"', show_two_window=True)

User avatar
Hurricanedragon
Newbie
Posts: 8
Joined: Wed Dec 10, 2014 1:47 pm
Deviantart: Hurricanedragon
Contact:

Re: My Side Image Won't Stay...

#5 Post by Hurricanedragon » Sat Oct 10, 2015 2:20 pm

Taking out the show statement didn't take away the error, and I don't think I've overwritten the centered statement with anything.

I wanted to make it so that the main character's image would still be there even when she's not the character speaking. When I use the traditional code for side images, her image pops in only when she's talking and then disappears when she's not, making it really distracting when there are conversations.

Here is the full traceback if it helps:

Code: Select all

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

Full traceback:
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\bootstrap.py", line 281, in bootstrap
    renpy.main.main()
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\main.py", line 468, in main
    run(restart)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\main.py", line 142, in run
    renpy.execution.run_context(True)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\execution.py", line 700, in run_context
    context.run()
  File "game/script.rpy", line 192, in script
    centered "{color=#fff}{i}RING-DING DING-DONG.{/i}{/color}"
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\ast.py", line 594, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\exports.py", line 1032, in say
    who(what, interact=interact)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\character.py", line 826, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\character.py", line 688, in do_display
    **display_args)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\character.py", line 491, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\ui.py", line 277, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\core.py", line 2346, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\core.py", line 2683, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\core.py", line 1785, in draw_screen
    renpy.config.screen_height,
  File "renpy/display/render.pyx", line 394, in renpy.display.render.render_screen (gen\renpy.display.render.c:6190)
    rv = render(root, width, height, 0, 0)
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 650, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 103, in renpy.display.render.render (gen\renpy.display.render.c:3104)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 650, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 103, in renpy.display.render.render (gen\renpy.display.render.c:3104)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 650, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 103, in renpy.display.render.render (gen\renpy.display.render.c:3104)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\screen.py", line 610, in render
    child = renpy.display.render.render(self.child, w, h, st, at)
  File "renpy/display/render.pyx", line 103, in renpy.display.render.render (gen\renpy.display.render.c:3104)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 650, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 103, in renpy.display.render.render (gen\renpy.display.render.c:3104)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "renpy/display/accelerator.pyx", line 104, in renpy.display.accelerator.transform_render (gen\renpy.display.accelerator.c:1904)
    cr = render(child, widtho, heighto, st - self.child_st_base, at)
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 282, in render
    surf = render(self.child, width, height, st, at)
  File "renpy/display/render.pyx", line 103, in renpy.display.render.render (gen\renpy.display.render.c:3104)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 185, in renpy.display.render.render (gen\renpy.display.render.c:2721)
    rv = d.render(widtho, heighto, st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 1127, in render
    self.update(st, at)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 1114, in update
    child, redraw = self.function(st, at, *self.args, **self.kwargs)
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 1177, in condition_switch_show
    return condition_switch_pick(switch), None
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\display\layout.py", line 1171, in condition_switch_pick
    if renpy.python.py_eval_bytecode(code):
  File "C:\Users\Ash\Documents\Ren'py\renpy-6.17.3-sdk\renpy\python.py", line 1472, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "<none>", line 1, in <module>
NameError: name 'sa' is not defined
'Sariya' changes to 'sa' depending on what letters I use to define the character, but that's the only noticeable change.

The regular code I use (the one where the image only shows when she's talking) is:

Code: Select all

##Sariya
define sa = Character('Sariya', color="#FFFFFF", what_prefix='"', 
    what_suffix='"', show_two_window=True, image="sar")

image side sar wnormal = "Sariya/Sari_W_Normal.png"
image side sar whappy = "Sariya/Sari_W_Happy.png"
image side sar wderp = "Sariya/Sari_W_Derp.png"
image side sar wlove = "Sariya/Sari_W_Love.png"
image side sar wmad = "Sariya/Sari_W_Mad.png"
image side sar wangry = "Sariya/Sari_W_Angry.png"
image side sar wsad = "Sariya/Sari_W_Sad.png"
image side sar wyay = "Sariya/Sari_W_Yay.png"
image side sar wsorry = "Sariya/Sari_W_Sorry.png"
image side sar wupset = "Sariya/Sari_W_Upset.png"
image side sar wproud = "Sariya/Sari_W_Proud.png"
image side sar welated = "Sariya/Sari_W_Elated.png"
image side sar wcute = "Sariya/Sari_W_Cute.png"
image side sar wconfused = "Sariya/Sari_W_Confused.png"
image side sar wemba = "Sariya/Sari_W_Embarrassed.png"

label start:

   s wnormal "Now you see me."

  "Now you don't"


User avatar
Hurricanedragon
Newbie
Posts: 8
Joined: Wed Dec 10, 2014 1:47 pm
Deviantart: Hurricanedragon
Contact:

Re: My Side Image Won't Stay...

#6 Post by Hurricanedragon » Sat Oct 10, 2015 2:33 pm

I figured it out~!!

I just took the original code and plugged in image ="sar" with all the characters like so:

Code: Select all

define s = Character('Sariya', color="#FFFFFF", what_prefix='"', 
    what_suffix='"', show_two_window=True, image="sar")
define eve = Character('Eve', color="#FFFFFF", what_prefix='"',
                         what_suffix='"', show_two_window=True, image="sar")
define who = Character('???', color="#FFFFFF", what_prefix='"',
                         what_suffix='"', show_two_window=True, image="sar")
... and she stays! I think this is what you meant by the usual approach?

Thanks for your help! It finally works~ :D

User avatar
Steamgirl
Veteran
Posts: 322
Joined: Sat Jul 28, 2012 4:39 am
Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
Projects: Stranded Hearts, Emma: A Lady's Maid
Deviantart: steamgirlgame
Contact:

Re: My Side Image Won't Stay...

#7 Post by Steamgirl » Sat Oct 10, 2015 2:42 pm

Haha! The original error is still a mystery, but glad it worked out in the end! ^_^

User avatar
BlackDragonHunt
Newbie
Posts: 8
Joined: Fri Oct 09, 2015 6:33 am
Organization: MangaGamer
Contact:

Re: My Side Image Won't Stay...

#8 Post by BlackDragonHunt » Sat Oct 10, 2015 4:14 pm

You seem to have found a solution that works for you, but in the interest of helping others who might run into similar problems, I wanted to point out the issue with your original code. Your ConditionSwitch is missing commas after the image filenames, which is what caused your error. It should be:

Code: Select all

    image sariya_side = ConditionSwitch(
        "sa == 'wnormal'", "Sariya/Sari_W_Normal.png",
        "sa == 'whappy'", "Sariya/Sari_W_Happy.png",
        "sa == 'wderp'", "Sariya/Sari_W_Derp.png",
        "sa == 'wlove'","Sariya/Sari_W_Love.png",
        "sa == 'wmad'", "Sariya/Sari_W_Mad.png",
        "sa == 'wangry'", "Sariya/Sari_W_Angry.png",
        "sa == 'wsad'", "Sariya/Sari_W_Sad.png",
        "sa == 'wyay'", "Sariya/Sari_W_Yay.png",
        "sa == 'wsorry'", "Sariya/Sari_W_Sorry.png",
        "sa == 'wupset'", "Sariya/Sari_W_Upset.png",
        "sa == 'wproud'", "Sariya/Sari_W_Proud.png",
        "sa == 'welated'", "Sariya/Sari_W_Elated.png",
        "sa == 'wcute'", "Sariya/Sari_W_Cute.png",
        "sa == 'wconfused'", "Sariya/Sari_W_Confused.png",
        "sa == 'wemba'", "Sariya/Sari_W_Embarrassed.png",
    )
Python concatenates adjacent strings, so without the commas, it's interpreting it as this:

Code: Select all

    image sariya_side = ConditionSwitch(
        "sa == 'wnormal'", "Sariya/Sari_W_Normal.pngsa == 'whappy'",
        "Sariya/Sari_W_Happy.pngsa == 'wderp'", "Sariya/Sari_W_Derp.pngsa == 'wlove'",
        "Sariya/Sari_W_Love.pngsa == 'wmad'", "Sariya/Sari_W_Mad.pngsa == 'wangry'",
        "Sariya/Sari_W_Angry.pngsa == 'wsad'", "Sariya/Sari_W_Sad.pngsa == 'wyay'",
        "Sariya/Sari_W_Yay.pngsa == 'wsorry'", "Sariya/Sari_W_Sorry.pngsa == 'wupset'",
        "Sariya/Sari_W_Upset.pngsa == 'wproud'", "Sariya/Sari_W_Proud.pngsa == 'welated'",
        "Sariya/Sari_W_Elated.pngsa == 'wcute'", "Sariya/Sari_W_Cute.pngsa == 'wconfused'",
        "Sariya/Sari_W_Confused.pngsa == 'wemba'", "Sariya/Sari_W_Embarrassed.png"
    )
Which is why it's telling you "Sariya" is not defined--because it's processing half of them as malformed conditions. However, you also have "sa" defined as a Character, and are comparing it to a string, so even with the commas added, you would have gotten an error about it not being able to choose a displayable.

User avatar
Hurricanedragon
Newbie
Posts: 8
Joined: Wed Dec 10, 2014 1:47 pm
Deviantart: Hurricanedragon
Contact:

Re: My Side Image Won't Stay...

#9 Post by Hurricanedragon » Sun Oct 11, 2015 7:25 pm

Oohhhh!! That's what the problem was! Thank you so much!!!

Post Reply

Who is online

Users browsing this forum: Jacksono