Page 1 of 1

Calling a screen when a character appears

Posted: Mon Dec 21, 2015 10:24 pm
by Hijiri
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?

Re: Calling a screen when a character appears

Posted: Mon Dec 21, 2015 11:50 pm
by Zetsubou
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)

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 12:45 am
by philat
Do you want the screen to be shown or called? What are you trying to do specifically?

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 2:06 am
by Hijiri
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."

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 3:15 am
by philat
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

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 5:48 am
by xela
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...

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 6:07 am
by philat
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.

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 7:03 am
by xela
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 :(

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 10:50 am
by Starshine
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

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 4:21 pm
by xela
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 :(

Re: Calling a screen when a character appears

Posted: Tue Dec 22, 2015 6:53 pm
by Starshine
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! :)