lipflap not working but eyeblink does.

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
lemonlimeface
Newbie
Posts: 4
Joined: Thu Oct 23, 2014 8:47 pm
Tumblr: ghostpanda
Contact:

lipflap not working but eyeblink does.

#1 Post by lemonlimeface »

I'm trying to get the eyes and mouth to animate. The eyes will blink at random intervals just fine, but the mouth refuses to move. I have the cps set to 15.

Here is my script:

Code: Select all

init python:
  
    # This is set to the name of the character that is speaking, or
    # None if no character is currently speaking.
    speaking = erin
  
    # This returns speaking if the character is speaking, and done if the
    # character is not.
    def while_speaking(erin, speak_d, done_d, st, at):
        if speaking == erin:
            return speak_d, .1
        else:
            return done_d, None
  
    # Curried form of the above.
    curried_while_speaking = renpy.curry(while_speaking)
  
    # Displays speaking when the named character is speaking, and done otherwise.
    def WhileSpeaking(erin, speaking_d, done_d=Null()):
        return DynamicDisplayable(curried_while_speaking(erin, speaking_d, done_d))
  
    # This callback maintains the speaking variable.
    def speaker_callback(erin, event, **kwargs):
        global speaking
       
        if event == "show":
            speaking = erin
        elif event == "slow_done":
            speaking = None
        elif event == "end":
            speaking = None
  
    # Curried form of the same.
    speaker = renpy.curry(speaker_callback)
    
    # Create such a character.
define erin = Character("Erin", callback=speaker("erinhappy"))
  
 # Composite things together to make a character with blinking eyes and
 # lip-flap.
image erinhappy = LiveComposite(
    (100, 780),
    (0, 0), "erinbasehappy.png",
    (0, 0), "erin eyes normal",
    (0, 0), WhileSpeaking("erin", "erin mouth happy", "mouth3.png"),
    )

image erin eyes normal:
    "erineyes1.png"
    choice:
        5.5
    choice:
        4.5
    choice:
        3.5
    # This randomizes the time between blinking.
    "erineyes2.png"
    0.1
    "erineyes3.png"
    0.1
    "erineyes2.png"
    0.1
    repeat
    
image erin mouth happy:
    "mouth1.png"
    .1
    "mouth2.png"
    .1
    "mouth3.png"
    .1
    repeat
I don't know what I'm doing wrong, help would be really appreciated!

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: lipflap not working but eyeblink does.

#2 Post by Tayruu »

Your character callback for Erin is referring to "erinhappy", but the WhileSpeaking in your portrait checks if speaking is "erin" (the first value).

You need the character to use "erin" in the callback, and then every expression's WhileSpeaking should check for "erin". If any of them are different, you would have to have a different Character() associated with every portrait.

The speaker value is equal to an overall name referred to inside the WhileSpeaking function, because speaker is giving WhileSpeaking what to check for. It isn't the name of the Character() or image.

EDIT: Actually throughout the definitions for the speaking function you seem to refer to "erin", sometimes not as a string, which would be unwise. Though offhand I'm not sure what you're trying to do that way. My code block is like this -- it has 'name' in places, or None:

Code: Select all

    # Speaker code
    speaking = None
  
    def while_speaking(name, speak_d, done_d, st, at):
        if speaking == name:
            return speak_d, .1
        else:
            return done_d, None
    curried_while_speaking = renpy.curry(while_speaking)
  
    def WhileSpeaking(name, speaking_d, done_d=Null()):
        return DynamicDisplayable(curried_while_speaking(name, speaking_d, done_d))
  
    def speaker_callback(name, event, **kwargs):
        global speaking
        if event == "show":
            speaking = name
        elif event == "slow_done":
            speaking = None
        elif event == "end":
            speaking = None
    speaker = renpy.curry(speaker_callback)

User avatar
lemonlimeface
Newbie
Posts: 4
Joined: Thu Oct 23, 2014 8:47 pm
Tumblr: ghostpanda
Contact:

Re: lipflap not working but eyeblink does.

#3 Post by lemonlimeface »

Thank you for your help. I made the changes but it still isn't working. :(

Here's the code now:

Code: Select all

init python:
  
    speaking = None
  
    
    def while_speaking(name, speak_d, done_d, st, at):
        if speaking == name:
            return speak_d, .1
        else:
            return done_d, None
  
    
    curried_while_speaking = renpy.curry(while_speaking)
  
   
    def WhileSpeaking(name, speaking_d, done_d=Null()):
        return DynamicDisplayable(curried_while_speaking(name, speaking_d, done_d))
  
   
    def speaker_callback(name, event, **kwargs):
        global speaking
       
        if event == "show":
            speaking = name
        elif event == "slow_done":
            speaking = None
        elif event == "end":
            speaking = None
  
  
    speaker = renpy.curry(speaker_callback)
    
    
define Erin = Character("Erin", callback=speaker("Erin"))
  
 
image erinhappy = LiveComposite(
    (100, 780),
    (0, 0), "erinbasehappy.png",
    (0, 0), "erin eyes normal",
    (0, 0), WhileSpeaking("erin", "erin mouth happy", "mouth3.png"),
    )

image erin eyes normal:
    "erineyes1.png"
    choice:
        5.5
    choice:
        4.5
    choice:
        3.5
    # This randomizes the time between blinking.
    "erineyes2.png"
    0.1
    "erineyes3.png"
    0.1
    "erineyes2.png"
    0.1
    repeat
    
image erin mouth happy:
    "mouth1.png"
    .1
    "mouth2.png"
    .1
    "mouth3.png"
    .1
    repeat

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: lipflap not working but eyeblink does.

#4 Post by PyTom »

Are you on 6.18.3? There were fixes.
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
lemonlimeface
Newbie
Posts: 4
Joined: Thu Oct 23, 2014 8:47 pm
Tumblr: ghostpanda
Contact:

Re: lipflap not working but eyeblink does.

#5 Post by lemonlimeface »

Yeah I have the latest version of ren'py.

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: lipflap not working but eyeblink does.

#6 Post by Tayruu »

You have define Erin = Character("Erin", callback=speaker("Erin")), but then (0, 0), WhileSpeaking("erin", "erin mouth happy", "mouth3.png"),. The issue is the capitalisation - the script sees "Erin" as not the same as "erin". I just did a similar edit in my own code, and lip-flap stopped working, so try fixing that.

User avatar
lemonlimeface
Newbie
Posts: 4
Joined: Thu Oct 23, 2014 8:47 pm
Tumblr: ghostpanda
Contact:

Re: lipflap not working but eyeblink does.

#7 Post by lemonlimeface »

Made that change... STILL not working. I only changed the capitalization. But I really appreciate your help because this problem is driving me crazy!

Post Reply

Who is online

Users browsing this forum: Google [Bot]