Another difficulty with Live Composite

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
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Another difficulty with Live Composite

#1 Post by lovebby »

Never mind, it wants to work now!
Alright so I've been able to use it alright and everything works as it should, until I get to return, and I get this error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/_layout/screen_main_menu.rpym", line 11, in script
  File "game/clothingtest.rpy", line 85, in python
NameError: global name 'eeli' is not defined

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

Full traceback:
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\ast.py", line 718, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 11, in <module>
    $ ui.interact()
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 1853, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 2092, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 252, in visit_all
    callback(self)
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 2092, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Cedes\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 1009, in per_interact
    child, _ = self.function(self.st, self.at, *self.args, **self.kwargs)
  File "game/clothingtest.rpy", line 85, in draw_Eli
    (0, 0), "c/eli/eye%s.png"%eeli,
NameError: global name 'eeli' is not defined

Windows-7-6.1.7601-SP1
Ren'Py 6.15.7.374
A Ren'Py Game 0.0
And here is what I have:

Code: Select all

init python:
   
    def draw_Eli(st, at):
        return LiveComposite(
            (415, 593),
            (0, 0), "c/eli/base.png",
            (0, 0), "c/eli/eye%s.png"%eeli,
            (0, 0), "c/eli/eyebrow%s.png"%beli,            
            (0, 0), "c/eli/hairbase.png",
            (0, 0), "c/eli/hairpony.png",
            (0, 0), "c/eli/mouth%s.png"%meli,
            ),.1
   
image eliclose = "c/eli/eyeclosed.png"
image elihappy = "c/eli/mouthhappy.png"
   
init:
    image Eli = DynamicDisplayable(draw_Eli)
   
    define Eli = Character('Eli')

label clotest:
 
    scene black
   
    # make sure variables are defined before using them
   
    $ eeli, meli, beli = 'eliopen', 'elismile', 'elilow'
    show Eli
    Eli "Oh, hello."

    $ eeli, meli, = 'eliclose', 'elihappy'  # this automatically updates the picture
    Eli "I'm happy to see you!"

    return
As I said, it all works fine until return pops up, and I don't know?
Last edited by lovebby on Thu Dec 12, 2013 4:22 pm, edited 2 times in total.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Some difficulty with uh Live Composite

#2 Post by xavimat »

Hi, lovebby!
You need some modifications to the original code, because you have named differently your images (and yes, the important thing is in the %).
The original code uses images named this way:
# e1.png, e2.png, e3.png, e4.png, e5.png (eyes)
# h1.png, h2.png, h3.png, h4.png, h5.png (hair)
# m1.png, m2.png, m3.png, m4.png, m5.png (mouth)
And then, uses the variables 'e', 'h', 'm' with numbers.

Your images seem named this way:
# mouthsmile.png
# mouthhappy.png
# ...
Then you need to set your variables to strings this way:
$ e, m = 'open', 'smile' # <- Don't forget the quotes!

In the definition of the function, instead of using '%d' you need '%s'. This means that the variable is a string, not a number.

Code: Select all

init python:
    def draw_Eli(st, at):
        return LiveComposite(
            (415, 593),
            (0, 0), "c/eli/base.png",
            (0, 0), "c/eli/hairbase.png",
            (0, 0), "c/eli/hairpony.png",
            # ...
            (0, 0), "c/eli/mouth%s.png"%m, # <- I'm considering only this line now
            # ...
            ),.1
The line does this: takes the string in the variable 'm' and inserts it to the string 'c/eli/mouth[HERE].png'.
You have to name the other images the same way, for example:
# eyesopen.png
# eyesclosed.png
And then the variable 'e' can be
$ e = 'open'
OR
$ e = 'closed'
The line in the definition should be: (0, 0), "c/eli/eyes%s.png"%e,
It's a simple "build your string" with a fixed part and a variable part. The result must be an actual image in your game.

Another thing, when I use Dynamic displayable, I put the first definition of the variables before the function, just in case. The final code could be this:

Code: Select all

init python:
    
    e, m, b = 'open', 'smile', 'low'
    
    def draw_Eli(st, at):
        return LiveComposite(
            (415, 593),
            (0, 0), "c/eli/base.png",
            (0, 0), "c/eli/hairbase.png",
            (0, 0), "c/eli/hairpony.png",
            (0, 0), "c/eli/eyes%s.png"%e,
            (0, 0), "c/eli/mouth%s.png"%m,
            (0, 0), "c/eli/eyebrow%s.png"%b,
            ),.1
    # I'm assuming that you have this images:
    
    # The base images:    
    # game/c/eli/base.png
    # game/c/eli/hairbase.png
    # game/c/eli/hairpony.png
    
    # The changing images:
    # game/c/eli/eyesopen.png
    # game/c/eli/eyesclosed.png
    # game/c/eli/eyesWHATEVER.png
    # game/c/eli/mouthsmile.png
    # game/c/eli/mouthhappy.png
    # game/c/eli/mouthWHATEVER.png
    # game/c/eli/eyebrowlow.png
    # game/c/eli/eyebrowhigh.png
    # game/c/eli/eyebrowWHATEVER.png
    # AND SO ON...
    
init:
    image Eli = DynamicDisplayable(draw_Eli)
   
    define Eli = Character('Eli')

label start:
 
    scene black
   
    # make sure variables are defined before using them
   
    $ e, m, b = 'open', 'smile', 'low'
    show Eli
    Eli "Oh, hello."

    $ e, m, b = 'close', 'happy', 'high' # this automatically updates the picture
    Eli "I'm happy to see you!"

    return
    
(I haven't covered here the side image)
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Re: Some difficulty with uh Live Composite

#3 Post by lovebby »

Wah, that did it! Thank you so much!
AH this makes things a lot more easier, aha.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Some difficulty with uh Live Composite

#4 Post by xavimat »

You're welcome! :D
DynamicDisplayable it's a powerful feature, but requires a bit of coding.
Let us know if you need more help.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Re: Another difficulty with Live Composite

#5 Post by lovebby »

Came across another difficulty!

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Another difficulty with Live Composite

#6 Post by xela »

lovebby wrote:Came across another difficulty!
You could define some defaults for eeli, meli and beli in init, that would solve the issue. Such code may be error proned when saving but I've never worked with LiveComposite before so I am not 100% positive on how it's usually done.

PS: As was suggested to you by xavimat btw:

init python:

e, m, b = 'open', 'smile', 'low'

def draw_Eli(st, at):
return LiveComposite(
(415, 593),
(0, 0), "c/eli/base.png",
(0, 0), "c/eli/hairbase.png",
(0, 0), "c/eli/hairpony.png",
(0, 0), "c/eli/eyes%s.png"%e,
(0, 0), "c/eli/mouth%s.png"%m,
(0, 0), "c/eli/eyebrow%s.png"%b,
),.1
Like what we're doing? Support us at:
Image

User avatar
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Re: Another difficulty with Live Composite

#7 Post by lovebby »

I get the same error when I define it however. And there's a little odd switchback when the sprite leaves the screen where it leaves with its default so I left it out and it played just fine before.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Another difficulty with Live Composite

#8 Post by xela »

lovebby wrote:I get the same error when I define it however. And there's a little odd switchback when the sprite leaves the screen where it leaves with its default so I left it out and it played just fine before.
I don't understand the new error descrition... and it should have really fixed the old one.
Like what we're doing? Support us at:
Image

User avatar
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Re: Another difficulty with Live Composite

#9 Post by lovebby »

Yeah, still no luck though. D:

User avatar
lovebby
Regular
Posts: 106
Joined: Mon Sep 09, 2013 12:24 am
Deviantart: lovebby
Contact:

Re: Another difficulty with Live Composite

#10 Post by lovebby »

It's still acting up, but it works fine in another game I coded? D:

Slytex
Newbie
Posts: 13
Joined: Sat Apr 07, 2012 5:58 am

Re: Some difficulty with uh Live Composite

#11 Post by Slytex »

xavimat wrote:Hi, lovebby!
You need some modifications to the original code, because you have named differently your images (and yes, the important thing is in the %).
The original code uses images named this way:
# e1.png, e2.png, e3.png, e4.png, e5.png (eyes)
# h1.png, h2.png, h3.png, h4.png, h5.png (hair)
# m1.png, m2.png, m3.png, m4.png, m5.png (mouth)
And then, uses the variables 'e', 'h', 'm' with numbers.
that worked for me too, thx

Post Reply

Who is online

Users browsing this forum: No registered users