Calling a screen when a character appears

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
Hijiri
Eileen-Class Veteran
Posts: 1515
Joined: Sun Mar 25, 2012 6:35 pm
Completed: Death Rule:lost code Overdrive Edition, Where the White Doves Rest-Tsumihanseishi
Projects: Death Rule: Killing System
Organization: MESI Games
IRC Nick: Hizi
Tumblr: mesigames
Skype: kurotezuka
itch: hijiri
Location: Los Angeles
Contact:

Calling a screen when a character appears

#1 Post by Hijiri » Mon Dec 21, 2015 10:24 pm

I was wondering if there's a way to have a screen be shown every time a certain character speaks. I know I can do this the old fashioned way by calling the screen each time, but is there a way to add it to the defined character?
Image Image
"Perfection goal that always changes. Can pursue, cannot obtain."

User avatar
Zetsubou
Veteran
Posts: 490
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Calling a screen when a character appears

#2 Post by Zetsubou » Mon Dec 21, 2015 11:50 pm

Incomplete solution, but I believe you're looking for something like:

Code: Select all

init python early:
    def callback_transition(event, interact=True, **kwargs):
        if interact and event == "begin":
            renpy.show_screen("screen_name")
        #elif interact and event == "end": #to hide when they finish speaking
        #  renpy.hide_screen("screen_name")

define test = Character("Test character", callback=callback_transition)
Last edited by Zetsubou on Tue Dec 22, 2015 1:04 am, edited 1 time in total.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

philat
Eileen-Class Veteran
Posts: 1635
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Calling a screen when a character appears

#3 Post by philat » Tue Dec 22, 2015 12:45 am

Do you want the screen to be shown or called? What are you trying to do specifically?

User avatar
Hijiri
Eileen-Class Veteran
Posts: 1515
Joined: Sun Mar 25, 2012 6:35 pm
Completed: Death Rule:lost code Overdrive Edition, Where the White Doves Rest-Tsumihanseishi
Projects: Death Rule: Killing System
Organization: MESI Games
IRC Nick: Hizi
Tumblr: mesigames
Skype: kurotezuka
itch: hijiri
Location: Los Angeles
Contact:

Re: Calling a screen when a character appears

#4 Post by Hijiri » Tue Dec 22, 2015 2:06 am

philat wrote:Do you want the screen to be shown or called? What are you trying to do specifically?
Well I guess I can show it:


The code I use right now is:

Code: Select all

##Screens
screen Dev_tag ():
    zorder 999
    add "ui/namebox/Dev.png" xpos -27 ypos 553
screen Greg_tag ():
    zorder 999
    add "ui/namebox/Greg.png" xpos -27 ypos 553

##Script
start:
    show screen Dev_tag
    $ renpy.transition(dissolve)
    D"This is a test."
    D"And this is to see if the screen remains."
    hide screen Dev_tag
    show screen Greg_tag
    $ renpy.transition(dissolve)
    G"And this test is to see if I can change the names with little notice."
    G"Hopefully it does because then I think I found an answer to my namebox problem."
    hide screen Greg_tag
    $ renpy.transition(dissolve)
    "And if this works, then the nametag should disappear with little issue."
Image Image
"Perfection goal that always changes. Can pursue, cannot obtain."

philat
Eileen-Class Veteran
Posts: 1635
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Calling a screen when a character appears

#5 Post by philat » Tue Dec 22, 2015 3:15 am

As far as I can tell, literally the only reason to do this is to apply transitions to the namebox, and this is a lot of effort for that...

If you're going to expend that much effort in the first place, I would propose that having a ConditionSwitch with transitions would be more efficient than using a callback to show a screen. See TransitionConditionSwitch here: http://lemmasoft.renai.us/forums/viewto ... 12#p326683

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

Re: Calling a screen when a character appears

#6 Post by xela » Tue Dec 22, 2015 5:48 am

Hijiri wrote:I was wondering if there's a way to have a screen be shown every time a certain character speaks.
Barring the fancy two bits of advice from above (both of which should work), lets not forget that there is a screen that is shown every time someone is speaking:

screen say(who

You should be able to condition it with the who argument passed to it and show any number of screens through if/showif + use/timers applying any transition/atl and etc. I never tried this exactly but similar things worked for me in the past really, really well and this seems like the easiest solution. Just note that I am still unclear as to what you're trying to do exactly even after watching the video so I am just responding to OP, if your wish is too show fancy screens conditioned of Characters every time that they speak, this would not be the worst way of handing that...
Like what we're doing? Support us at:
Image

philat
Eileen-Class Veteran
Posts: 1635
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Calling a screen when a character appears

#7 Post by philat » Tue Dec 22, 2015 6:07 am

The issue is (at least, I imagine) that you can't apply a transition/ATL to the who element/box in screen say, because it's reshown every interaction and/or run behind the scenes (for prediction and other reasons). I mean, what people want is for the namebox to dissolve in/out when the character changes, not every time there's a new line. This is a question I see pop up every so often on the forums, but I've never seen a particularly easy fix for it.

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

Re: Calling a screen when a character appears

#8 Post by xela » Tue Dec 22, 2015 7:03 am

philat wrote:...
You're right. I remembered playing this cat/mouse game with say screen before, although winning in the end, code was absolutely awful :(
Like what we're doing? Support us at:
Image

User avatar
Starshine
Veteran
Posts: 247
Joined: Mon Jan 30, 2012 7:50 am
Completed: http://berry-melon.blogspot.co.uk/2016/ ... -2016.html
Projects: Pancake Surprise (2016)
Tumblr: http://bettybooplover.tumblr.com
Deviantart: berry-melon
Soundcloud: sweepea-1
Contact:

Re: Calling a screen when a character appears

#9 Post by Starshine » Tue Dec 22, 2015 10:50 am

philat wrote:Do you want the screen to be shown or called? What are you trying to do specifically?
I think he wants to show a side image, when the text appears.

http://www.renpy.org/doc/html/side_image.html
http://berry-melon.blogspot.com
I'm not resting until I find
What would make your eyes
Glisten like mine
With loves divine!

Boo-Boo I couldn't aspire....to anything...
Higher...than to fill that one desire to make it
My own....Bop-Bop-a-Dop-Boop-Oop-a-Doop honey?

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

Re: Calling a screen when a character appears

#10 Post by xela » Tue Dec 22, 2015 4:21 pm

Starshine wrote:I think he wants to show a side image, when the text appears.
Maybe... but that's not how I understood it. My guess is that OP wants to add automatic transition when switching between characters and just for those character names. Ren'Py does not seem to offer that functionality out of the box and any approach suggested there or that I could think of results in some weird and sh!tty code :(
Like what we're doing? Support us at:
Image

User avatar
Starshine
Veteran
Posts: 247
Joined: Mon Jan 30, 2012 7:50 am
Completed: http://berry-melon.blogspot.co.uk/2016/ ... -2016.html
Projects: Pancake Surprise (2016)
Tumblr: http://bettybooplover.tumblr.com
Deviantart: berry-melon
Soundcloud: sweepea-1
Contact:

Re: Calling a screen when a character appears

#11 Post by Starshine » Tue Dec 22, 2015 6:53 pm

xela wrote:
Starshine wrote:I think he wants to show a side image, when the text appears.
Maybe... but that's not how I understood it. My guess is that OP wants to add automatic transition when switching between characters and just for those character names. Ren'Py does not seem to offer that functionality out of the box and any approach suggested there or that I could think of results in some weird and sh!tty code :(
Oh, I see! :)
http://berry-melon.blogspot.com
I'm not resting until I find
What would make your eyes
Glisten like mine
With loves divine!

Boo-Boo I couldn't aspire....to anything...
Higher...than to fill that one desire to make it
My own....Bop-Bop-a-Dop-Boop-Oop-a-Doop honey?

Post Reply

Who is online

Users browsing this forum: No registered users