Character dissolve running in background?

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
Twoflower
Regular
Posts: 41
Joined: Sat Feb 25, 2017 11:53 am
Completed: Arcade Spirits
Projects: Arcade Spirits
Organization: Fiction Factory Games
Tumblr: fictionfactorygames
Contact:

Character dissolve running in background?

#1 Post by Twoflower »

So, I'd like to set up a default transition which is used when a character changes emotional state. You know, like having a soft dissolve rather than a hard cut between these two lines:

Code: Select all

francine "I'm feeling okay."
francine happy "Now I'm feeling happy!"
Fortunately, Renpy has a feature that provides this!

Code: Select all

config.say_attribute_transition = Dissolve(0.5, alpha=True)
...but unfortunately, what happens if I set this is that the entire game grinds to a halt for half a second while it dissolves the image, complete with removing the side portrait and other UI elements during the transition. It's an awkward and distracting flicker and I really don't like it. Ideally what I want is for the dissolve to happen in the background, while the text box continues on its merry way, without disrupting anything.

I found one way to do it... but it's supremely awkward because it bypasses Renpy's normal emotion tagging system completely.

Code: Select all

francine "I'm feeling okay."
show francine normal:
   "francine happy" with dissolve
francine "Now I'm feeling happy! ...but if I say 'francine happy' in front of this line it'll still hard-cut."
Meaning every single time I want to change emotions I need to insert this extra two-line block of hard coded script. Closest I can get to abstracting it is to set up a transition called "dissolve_francine_happy" and issue a "show francine normal at dissolve_francine_happy" but that's STILL really clunky and still gets disrupted if I accidentally left in a normal renpy call of francine happy in the script.

Is there a better way to do this, ideally integrating it right into the normal Renpy say system for emotional states? I'd rather avoid having the whole game stop what it's doing and run the dissolve, disrupting my UI... and I'd like to avoid having to insert these clunky manually coded emotion shifts.
Image

User avatar
Black Cat 2412
Regular
Posts: 74
Joined: Wed Aug 16, 2017 10:10 am
Projects: Rapunzel: A classic retold
Deviantart: BlackCat2412
Location: Vietnam
Contact:

Re: Character dissolve running in background?

#2 Post by Black Cat 2412 »

I have encountered the same problem as you :viewtopic.php?f=8&t=45415, and I have seen others have too (in fact, if you scroll down then right in the same front page you will find another topic with the same question)
The sad news is: far as I know there is just noway to change this yet-it's an internal part of Renpy. I pmed Tom about it and he said:
If it's what I think is going on, there isn't a way to control it - it's just part of Ren'Py. While I might try to change this in the future, for now you need to design around it.
and that it's "an expected behavior" (which in my opinion kinda render this whole function useless)

So yeah, for now we just have to live with it. But I think that this has become large enough for serious consideration. Do anyone know how we can officially pitch this idea to Tom? (should there be a poll or something?)

User avatar
Twoflower
Regular
Posts: 41
Joined: Sat Feb 25, 2017 11:53 am
Completed: Arcade Spirits
Projects: Arcade Spirits
Organization: Fiction Factory Games
Tumblr: fictionfactorygames
Contact:

Re: Character dissolve running in background?

#3 Post by Twoflower »

Dang. Looks like you arrived at the same solution I did, i.e. a resource intensive hack of a solution.

Is there any way we could design a function to automate some of this? Like,

Code: Select all

call emotion("francine","happy")
...to automatically do the display of francine's last emotional state, dissolving into the new one? I can't figure out how to pass a variable to a show command, though; I keep getting 'can't take unicode as a parameter' or something.
Image

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Character dissolve running in background?

#4 Post by RicharDann »

You can use renpy.show(), show command's python equivalent to pass arguments to it.

Code: Select all

show eileen happy
Is equivalent to:

Code: Select all

$ renpy.show("eileen happy")
You could also write a function to automate the process as you mention, probably like this:

Code: Select all

image eileen = "eileen.png"

image eileen happy = "eileen_happy.png"
    
init python:
    
    def emotion(who, emotion): 
        whoem = who + " " + emotion
        renpy.show(whoem) 

# The game starts here.

label start:

    "Let's change her emotion"
    
    $ emotion("eileen", "happy")
The most important step is always the next one.

User avatar
Black Cat 2412
Regular
Posts: 74
Joined: Wed Aug 16, 2017 10:10 am
Projects: Rapunzel: A classic retold
Deviantart: BlackCat2412
Location: Vietnam
Contact:

Re: Character dissolve running in background?

#5 Post by Black Cat 2412 »

Uhm, where would I put my transition (say, a Dissolve(0.3) ) in your code? (Sorry, I'm a total noob at coding)

User avatar
Twoflower
Regular
Posts: 41
Joined: Sat Feb 25, 2017 11:53 am
Completed: Arcade Spirits
Projects: Arcade Spirits
Organization: Fiction Factory Games
Tumblr: fictionfactorygames
Contact:

Re: Character dissolve running in background?

#6 Post by Twoflower »

I tried this as a test:

Code: Select all

init python:  
    def emotion(who, emotion): 
        whoem = who + " " + emotion
        renpy.transition(Dissolve(2.0,alpha=True))
        renpy.show(whoem)
...and it SORTA works. Except the namebox and the text itself also dissolves into view, not just the new character sprite. How do I tell Renpy to ONLY apply the transition to the show statement and not to, well, everything in the game?
Image

User avatar
Twoflower
Regular
Posts: 41
Joined: Sat Feb 25, 2017 11:53 am
Completed: Arcade Spirits
Projects: Arcade Spirits
Organization: Fiction Factory Games
Tumblr: fictionfactorygames
Contact:

Re: Character dissolve running in background?

#7 Post by Twoflower »

Okay, I've got this working... but it is clunky as HELL.

Way it works is I keep a variable which records a per-character current emotional state, since there is no way to auto-detect this right now. (renpytom has said he's going to add a way to get the current displayed image tags, but that's forthcoming. It'll fix a lot of this but not all.) When I want to swap emotions, I call renpy.show with the old image, and a transform that pulls in a dynamic image which shapes itself to be the new image. This means a LOT of if-case statements and variables... I'm going to revamp this soon to use dynamic lists and stuff.

...or I may give up and just do the hardcoded emotions, because this is for the birds as a workaround. Anyway, here's my crappy code, for now. I'll keep working on it this weekend.


EDIT: Disregard that, it sucked way too much so I'm working on a better version. But I'll share my work when done. I've got it working, it's just recording the current state that's difficult.
Image

User avatar
Twoflower
Regular
Posts: 41
Joined: Sat Feb 25, 2017 11:53 am
Completed: Arcade Spirits
Projects: Arcade Spirits
Organization: Fiction Factory Games
Tumblr: fictionfactorygames
Contact:

Re: Character dissolve running in background?

#8 Post by Twoflower »

Well, crap. I almost had it working.

This is with the latest nightly build and the recent git checkin for modifying get_attributes that renpytom was nice enough to write for me. It ALMOST works... but because the new emotional state doesn't actually replace the tags on the old one (since it's really just a transform that overlays one on top of the other) it doesn't transition properly.

Code: Select all

label emotion(charname="",newstate=""):
   $ oldstate = str(renpy.get_attributes(charname)).replace("(u'","").replace("', u'"," ").replace("')","").replace("',)","")
   $ newstatetrans = newstate.replace(" ","_")
   python:
     renpy.show(charname + " " + oldstate, at_list=[eval(charname + "_" + newstatetrans)], tag=charname)
return
At this point I give up. I'm doing all this work so I can write "Character X is now Emotion Y" when I could just hardcode it and write "Character X was Emotion Y and is now Emotion Z". It's not THAT much work to go XYZ instead of XY, so, unless someone's got a better idea, I'll just hardcode.

All this so I can do soft and non-disruptive dissolves...
Image

mikolajspy
Regular
Posts: 169
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Too many, check signature
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Re: Character dissolve running in background?

#9 Post by mikolajspy »

Twoflower wrote: Fri Oct 13, 2017 5:06 pm I tried this as a test:

Code: Select all

        renpy.transition(Dissolve(2.0,alpha=True))
Try

Code: Select all

renpy.with_statement(dissolve)
It might work, I tried to do something similar, but I gave up, because it looks like I can't use "at" statement with function, so all nice "at left with easeinright" didn't work.

User avatar
Twoflower
Regular
Posts: 41
Joined: Sat Feb 25, 2017 11:53 am
Completed: Arcade Spirits
Projects: Arcade Spirits
Organization: Fiction Factory Games
Tumblr: fictionfactorygames
Contact:

Re: Character dissolve running in background?

#10 Post by Twoflower »

I also tried with_statement, but that caused the entire game to stop and wait for the transition to complete, making the namebox / side portrait flicker as a result.

Renpytom said that's just how renpy's transitions work, so that's out. The only bypass I've found is to show the original character sprite, with a transform that dissolves the new sprite on top of it. Disadvantage being it still has the tags of the old sprite.
Image

Post Reply

Who is online

Users browsing this forum: Andredron, Google [Bot], Semrush [Bot]