Question about "layered sprite" cookbook entry

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
Qu-ko
Regular
Posts: 54
Joined: Sun Jun 18, 2006 12:27 am
Location: Massachusetts, land of evil-ness
Contact:

Question about "layered sprite" cookbook entry

#1 Post by Qu-ko » Sat Nov 07, 2009 8:26 pm

...Um, hi, long time no post?

Anyway, I've just been fiddling around with Ren'Py lately, not really working actively on anything, mostly testing stuff out. And I've been trying to work the "layered sprite with different emotions" cookbook entry, but I seem to be having trouble. Knowing me, it's probably something very simple that I'm missing, but I think it has something to do with not turning off the sprite and then trying to go back to the main menu that's making it crash?

This is the code I'm using:

Code: Select all

init:

    image rei = ConditionSwitch(
            "rei_face == 'happy'", LiveComposite(
                (200, 256),
                (0, 0), "rei-body.png",
                (96, 88), Animation("rei-eyes11.png", 2.5,
                                                "rei-eyes12.png", 0.05,
                                                "rei-eyes13.png", 0.05,
                                                "rei-eyes12.png", 0.05),
                (112, 136), "rei-mouth1.png"
                ),
            "rei_face == 'sad'", LiveComposite(
                (200, 256),
                (0, 0), "rei-body.png",
                (96, 88), Animation("rei-eyes21.png", 2.5,
                                                "rei-eyes22.png", 0.05,
                                                "rei-eyes23.png", 0.05,
                                                "rei-eyes22.png", 0.05),
                (112, 136), "rei-mouth2.png"
                )
            )


    $ rei = Character('Rei', color="#5c628b")


label start:
    
    show rei
    $ rei_face = "happy"
    with dissolve

    rei "You've created a new Ren'Py game."
    
    $ rei_face = "sad"
    with dissolve

    rei "Once you add a story, pictures, and music, you can release it to the world!"
And this is the traceback:

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

NameError: name 'rei_face' is not defined

While running game code:
 - script at line 704 of renpy-6.9.3/common/00library.rpy
 - python at line 704 of renpy-6.9.3/common/00library.rpy.
 - script at line 20 of renpy-6.9.3/common/_layout/classic_main_menu.rpym

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

  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\bootstrap.py", line 260, in bootstrap
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\main.py", line 308, in main
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\main.py", line 92, in run
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\execution.py", line 230, in run
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\ast.py", line 558, in execute
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\python.py", line 921, in py_exec_bytecode
  File "renpy-6.9.3/common/00library.rpy", line 704, in <module>
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\game.py", line 285, in call_in_new_context
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\execution.py", line 230, in run
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\ast.py", line 558, in execute
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\python.py", line 921, in py_exec_bytecode
  File "renpy-6.9.3/common/_layout/classic_main_menu.rpym", line 53, in <module>
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\ui.py", line 69, in interact
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\core.py", line 1364, in interact
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\core.py", line 1663, in interact_core
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\core.py", line 983, in show
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 711, in render_screen
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\layout.py", line 485, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\transition.py", line 174, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\transition.py", line 348, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\layout.py", line 485, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\layout.py", line 485, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\image.py", line 143, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\image.py", line 35, in wrap_render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\layout.py", line 247, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\render.py", line 142, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\layout.py", line 825, in render
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\layout.py", line 862, in condition_switch_show
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\display\layout.py", line 856, in condition_switch_pick
  File "C:\Documents and Settings\Owner\Desktop\renpy-6.9.3\renpy\python.py", line 950, in py_eval
  File "<none>", line 1, in <expression>
NameError: name 'rei_face' is not defined

While running game code:
 - script at line 704 of renpy-6.9.3/common/00library.rpy
 - python at line 704 of renpy-6.9.3/common/00library.rpy.
 - script at line 20 of renpy-6.9.3/common/_layout/classic_main_menu.rpym

Ren'Py Version: Ren'Py 6.9.3c
...Probably should've attached those, but it's easier this way. :<

Um, so, there is clearly something my simple mind is missing here. Help?
ヾ(゚Д゚)ノ うわあああぁぁぁぁぁぁぁ―――――――

Melkoshi
Regular
Posts: 156
Joined: Tue Jun 02, 2009 8:56 pm
Projects: Jewels of Sytinane
Location: U.s.a.
Contact:

Re: Question about "layered sprite" cookbook entry

#2 Post by Melkoshi » Sat Nov 07, 2009 10:57 pm

Seems to me you left out a start for the rei_face veriable.

It needs to know what ti is, before it can be changed. makes sense?

so if you add a $ rei_face = happy in your init, it should work. and then change when you change the happy to other emotions.
--- My DeviantArt.
Game in Progress for demo-teaser:
story(script) = 45%
sprites = 100%
programming(interface) = 35%
CGs = 0%
Backgrounds = 5%
Music/sound = 0%

Heatth
Newbie
Posts: 16
Joined: Sun Jun 14, 2009 4:28 pm
Projects: Suzumiya Haruhi - Project Crossroads (temporary title)
Location: Brazil
Contact:

Re: Question about "layered sprite" cookbook entry

#3 Post by Heatth » Sat Nov 07, 2009 11:39 pm

You could also add a "rei_face == 'None'", rei-body.png) to the ConditionSwitch, as it is said at the cookbook. Then it woudn't crash. (it woudn't appear any face until you define rei_face either, of course)

User avatar
Qu-ko
Regular
Posts: 54
Joined: Sun Jun 18, 2006 12:27 am
Location: Massachusetts, land of evil-ness
Contact:

Re: Question about "layered sprite" cookbook entry

#4 Post by Qu-ko » Sun Nov 08, 2009 12:52 am

Heatth wrote:You could also add a "rei_face == 'None'", rei-body.png) to the ConditionSwitch, as it is said at the cookbook. Then it woudn't crash. (it woudn't appear any face until you define rei_face either, of course)
I think it was actually the init block $ rei_face = "happy" that I needed to make it not crash, since I'd had the "rei_face == 'None'", "rei-body.png" in the ConditionSwitch and it still crashed every time the game ended, so I took it out to experiment with why it was doing that.

Thanks, ahaha. *dumb*
ヾ(゚Д゚)ノ うわあああぁぁぁぁぁぁぁ―――――――

Alex

Re: Question about "layered sprite" cookbook entry

#5 Post by Alex » Sun Nov 08, 2009 7:00 am

Code: Select all

label start:
    
    show rei
    $ rei_face = "happy"
The problem was here. See, you tried to show <rei> before tell the Ren`py what condition she is.
So, you might set the <rei>s condition in init block, as Melkoshi said, or just change the order of lines like

Code: Select all

label start:
    
    $ rei_face = "happy"
    show rei
anyway, if you add new condition it should works like the others.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot]